Arm+linux Embedded development Environment Construction

Source: Internet
Author: User

These are from the beginning of January to learn the problems encountered in Arm+linux notes, I feel very useful, so share out!

Because there is no teacher to teach, their own pondering the problems encountered a lot, welcome to exchange!

--------------------------------------------------------------------------------------------------
0-point Drift Team: dust-sealed wave

---------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------
0. Platform Setup
--------------------------------------------------------------------------------------
Download VMware11
Download Ubutun 14
Installation

Solve gedit Chinese garbled characters
Terminal input:

Gsettings set org.gnome.gedit.preferences.encodings auto-detected "[' GB18030 ', ' GB2312 ', ' GBK ', ' UTF-8 ', ' BIG5 ', ' Current ', ' UTF-16 '] "


--------------------------------------------------------------------------------------
1.DNW Tool Installation
--------------------------------------------------------------------------------------
sudo apt-get install Libusb-dev


Dnw.c

#include <stdio.h>
#include <usb.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define Tq2440_secbulk_idvendor 0x5345
#define TQ2440_SECBULK_IDPRODUCT 0x1234


struct Usb_dev_handle * Open_port ()
{
struct Usb_bus *busses, *bus;

Usb_init ();
Usb_find_busses ();
Usb_find_devices ();

busses = Usb_get_busses ();
for (Bus=busses;bus;bus=bus->next)
{
struct Usb_device *dev;
for (Dev=bus->devices;dev;dev=dev->next)
{
if (Tq2440_secbulk_idvendor==dev->descriptor.idvendor
&& tq2440_secbulk_idproduct==dev->descriptor.idproduct)
{
printf ("Target USB device found!\n");
struct Usb_dev_handle *hdev = usb_open (dev);
if (!hdev)
{
Perror ("Cannot open device");
}
Else
{
if (0!=usb_claim_interface (Hdev, 0))
{
Perror ("Cannot claim interface");
Usb_close (Hdev);
Hdev = NULL;
}
}
return Hdev;
}
}
}

printf ("Target USB device not found!\n");

return NULL;
}

void usage ()
{
printf ("USAGE:DNW <file>\n\n");
}

unsigned char* prepare_write_buf (char *filename, unsigned int *len)
{
unsigned char *write_buf = NULL;
struct STAT fs;

int fd = open (filename, o_rdonly);
if ( -1==FD)
{
Perror ("Cannot open file");
return NULL;
}
if ( -1==fstat (FD, &FS))
{
Perror ("Cannot get file size");
Goto error;
}
Write_buf = (unsigned char*) malloc (FS.ST_SIZE+10);
if (NULL==WRITE_BUF)
{
Perror ("malloc failed");
Goto error;
}

if (fs.st_size! = Read (FD, write_buf+8, fs.st_size))
{
Perror ("Reading file failed");
Goto error;
}

printf ("FileName:%s\n", filename);
printf ("Filesize:%d bytes\n", fs.st_size);

* ((u_int32_t*) write_buf) = 0x30008000; Download Address

* ((u_int32_t*) write_buf+1) = Fs.st_size + 10; Download size;


*len = fs.st_size + 10;
return write_buf;

Error
if (fd!=-1) close (FD);
if (null!=write_buf) free (WRITE_BUF);
fs.st_size = 0;
return NULL;

}

int main (int argc, char *argv[])
{
if (2!=ARGC)
{
Usage ();
return 1;
}

struct Usb_dev_handle *hdev = Open_port ();
if (!hdev)
{
return 1;
}

unsigned int len = 0;
unsigned char* write_buf = Prepare_write_buf (argv[1], &len);
if (NULL==WRITE_BUF) return 1;

unsigned int remain = Len;
unsigned int towrite;
printf ("Writing data ... \ n");
while (remain)
{
Towrite = remain>512? 512:remain;
if (towrite! = Usb_bulk_write (Hdev, 0x03, write_buf+ (Len-remain), Towrite, 3000))
{
Perror ("Usb_bulk_write failed");
Break
}
Remain-=towrite;
printf ("\r%d%\t%d bytes", (len-remain) *100/len, Len-remain);
Fflush (stdout);
}
if (0==remain) printf ("done!\n");
return 0;
}

5 compilation: Gcc-o DNW Dnw.c-lusb

6. Copy the file to the/usr/local/bin directory
# sudo CP dnw/usr/local/bin


----------------------------------------------------------------------------------------------
2. ARM-LINUX-GCC Installation
----------------------------------------------------------------------------------------------
sudo apt-get install Gcc-arm-linux-gnueabi

Arm-linux-gnueabi-gcc-v

Remember: At the same time, modify the makefile to:
Arm-linux-gnueabi-gcc-g-c-o led_on.o led_on. S
Arm-linux-gnueabi-ld-ttext 0x0000000-g Led_on.o-o led_on_elf
Arm-linux-gnueabi-objcopy-o binary-s led_on_elf Led_on.bin

----------------------------------------------------------------------------------------------
3. Linux Serial Assistant Installation
----------------------------------------------------------------------------------------------
sudo apt-get minicom

Ctrl+a+z
Set serial port non-flow control: ttyUSB0

--------------------------------------------------------------------------------
4. minicom Sending files
--------------------------------------------------------------------------------
CTRL + S Select the file to send


-----------------------------------------------------------------------------------
5. Make Menuconfig * * * [scripts/kconfig/dochecklxdialog] compile kernel
------------------------------------------------------------------------------------
sudo apt-get install Ncurses-dev


-----------------------------------------------------------------------
6. Undefined reference to ' __stack_chk_fail '
Undefined reference to ' __stack_chk_guard '
-----------------------------------------------------------------------
Cflags was added-fno-stack-protector.


-----------------------------------------------------------------------
7. GUI Development
Download qt-creator-opensource-linux-x86_64-3.4.0
Download Qtcreator

-----------------------------------------------------------------------


------------------------------------------------------------------------
8.u-boot porting Linux Kernel porting

-----------------------------------------------------------------------


Write Driver xx_dev.c (GPIO_DEV.C) in the corresponding directory
Then write the application xx.c (GPIO.C)

In the same directory:

Kconfig
Adding support for the kernel in the kernel source code

Config tq2440_gpio_test
TriState "Embedsky sky2440/tq2440 Board GPIO Test (Control LED)"
Depends on arch_s3c2440
Default Y if arch_s3c2440
Help
GPIO control for Embedsky sky2440/tq2440 Board.

Makefile: The kernel directory is modified as a directory for the Development Board

Configure the driver to compile
obj-$ (config_tq2440_gpio_test) + = DEV_GPIO.O

Configuring the kernel: Make Menuconfig

Select it as M module
Compiling kernel make Zimage
Compile module Make subdir = Drivers/char/modules
Locate the Xx.ko in the corresponding directory to copy it to the Development Board
Insmod Xx.ko
Rmmod Xx.ko
Dmesg

--------------------------------------------------------------------------------

Arm+linux Embedded development Environment Construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.