Test Project Build
Let's test build with some examples provided by ST. First copy the GPIO/IOToggle source files to the project directory just created.
Then create a make file and linker script file for the project. In this state, you can build(F7) and clean the project as you typed in the previous post. Actually everything is done by make utility and CodeLite is just invoking it.
It would be nice you can navigate and edit each file. At the left Workspace pane, right click on the project name and select the "Import Files from Directory".
Then you can select directories(and files) you want to show on your Workspace pane, which will probably match the source list of your Makefile. If there is no (sub)directories to select, you can choose as many as you want by clicking the Browse button on the top right of the dialog.
Resulting directory structure probably matches the source list of your Makefile. Be sure to remember that this tree is created regardless of project structure itself and you are not suppose to compile each individual file.
Flash Utility Integration
You can bring up the external flash utilities by registering those as external tools. Select Plugins-> External tools ->Configure external tools or just click the corresponding button from the menu bar
Then you can register your flash program.
Surely it is not as convenient as a native flasher but it is still useful.
Monday, June 27, 2011
Sunday, June 26, 2011
STM32F GCC IDE on Windows(1)
You can easily build a GCC IDE for Cortex-M3 using a open source IDE. If you are not a big fan of Eclipse like me, you will probably like CodeLite or Geany. Both programs are cross platform, open source, and light-weight. Geany is more minimalistic of two. If you are familiar with Visual Studio, you will find CodeLite is more comfortable.
I'm going to use the following programs:
GCC and Make
For the CSG++ Lite, be sure to download the installer version(EABI). Install is straight forward. You don't have to change any settings. After install, you should add the following directory to your PATH.
> C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin
You can verify that your PATH is set up correctly by running
> arm-none-eabi-gcc -v
on your console window.
Other than the compiler collection, you may need at least GNU make utility. You can install Cygwin for the make utility. But the simplest way is using GnuWin32. Download and install the GnuWin32 make package. You also have to add its bin directory to you PATH. You can install as many GnuWin32 packages as you need.
> C:\Program Files\GnuWin32\bin
STM32F Library and CodeLite Project
Download the library(stm32f10x_stdperiph_lib.zip) and extract it on your work directory. Then install CodeLite and fire it up to create initial workspace and project. For convenience, create a Codelite workspace under the STM32F library directory. (Workspace->New Workspace)
By selecting the workspace name and path as shown and deselecting the "Create the workspace under a separate directory" check box, you can use the STM32F library project directory as your workspace. But it is only for convenience sake. You can choose your workspace anywhere you like.
Now create a new project.(Workspace->New Project)
For the Categories, choose "Others" then you can select "Custom Makefile" type for the template. Type in your project name. And select compiler type. Compiler type here is not important because you will use your own build and compile command strings. Resulting directory structure would be
For now, there is no file under GpioTest directory except the CodeLite project file.
After the project creation, go to the project settings by right click on the project "GpioTest" and select the last menu item.
Go to "Customize" on the left, then check "Enable custom build". You want change "Working Directory" from $(WorkspacePath) to $(ProjectPath) where you have your own Makefile. Now fill in the Build Command with "make" and the Clean Command with "make clean". In this way, you can use your Makefile to build your project instead of CodeLite's own makefile.
I'm going to use the following programs:
- GCC - CodeSourcery G++ Lite (EABI - windows - installer version)
- GNU Make - GnuWin32 make package
- Library - ST32F10x_StdPeriph_Lib
- IDE - CodeLite
- Flasher(Serial) - ST Flash Loader
- Flasher(USB) - Segger jlink flasher
GCC and Make
For the CSG++ Lite, be sure to download the installer version(EABI). Install is straight forward. You don't have to change any settings. After install, you should add the following directory to your PATH.
> C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin
You can verify that your PATH is set up correctly by running
> arm-none-eabi-gcc -v
on your console window.
Other than the compiler collection, you may need at least GNU make utility. You can install Cygwin for the make utility. But the simplest way is using GnuWin32. Download and install the GnuWin32 make package. You also have to add its bin directory to you PATH. You can install as many GnuWin32 packages as you need.
> C:\Program Files\GnuWin32\bin
STM32F Library and CodeLite Project
Download the library(stm32f10x_stdperiph_lib.zip) and extract it on your work directory. Then install CodeLite and fire it up to create initial workspace and project. For convenience, create a Codelite workspace under the STM32F library directory. (Workspace->New Workspace)
By selecting the workspace name and path as shown and deselecting the "Create the workspace under a separate directory" check box, you can use the STM32F library project directory as your workspace. But it is only for convenience sake. You can choose your workspace anywhere you like.
Now create a new project.(Workspace->New Project)
For the Categories, choose "Others" then you can select "Custom Makefile" type for the template. Type in your project name. And select compiler type. Compiler type here is not important because you will use your own build and compile command strings. Resulting directory structure would be
For now, there is no file under GpioTest directory except the CodeLite project file.
After the project creation, go to the project settings by right click on the project "GpioTest" and select the last menu item.
Go to "Customize" on the left, then check "Enable custom build". You want change "Working Directory" from $(WorkspacePath) to $(ProjectPath) where you have your own Makefile. Now fill in the Build Command with "make" and the Clean Command with "make clean". In this way, you can use your Makefile to build your project instead of CodeLite's own makefile.
Sunday, May 8, 2011
JLink with BeagleBoard
If you hook-up JLink to BeagleBoard and execute JLink commander, then you probably get the following error:
****** Error: DBEGN is not asserted.
And fail to recognise the target. This is because TI OMAP3530 needs a special setup sequence for JLink to connect, which is controlled by JLink script file (Default.JLinkScript)
Find the script file:
$JLINK_INST_DIR$\Samples\JLink\Scripts\ScriptBeagleBoard...
Copy it to the base directory(Windows) or the current directory(Linux) and rename it to
Default.JLinkScript
Then you can successfully connect to the board.
****** Error: DBEGN is not asserted.
And fail to recognise the target. This is because TI OMAP3530 needs a special setup sequence for JLink to connect, which is controlled by JLink script file (Default.JLinkScript)
Find the script file:
$JLINK_INST_DIR$\Samples\JLink\Scripts\ScriptBeagleBoard...
Copy it to the base directory(Windows) or the current directory(Linux) and rename it to
Default.JLinkScript
Then you can successfully connect to the board.
VMware Player on Xubuntu
Xubuntu : 10.10 / 11.04
VMware-Player : 3.1.3-385536
Be sure to install the following packages before installing vmware-player
- libglibmm-2.4-1c2a
- libgnomecanvasmm-2.6-1c2a
Otherwise you cannot fire-up the installer, not to mention the player itself.
If you encounter another issue after the install, check this out.
VMware-Player : 3.1.3-385536
Be sure to install the following packages before installing vmware-player
- libglibmm-2.4-1c2a
- libgnomecanvasmm-2.6-1c2a
Otherwise you cannot fire-up the installer, not to mention the player itself.
If you encounter another issue after the install, check this out.
Thursday, April 7, 2011
NTFS-3G options: umask, dmask, and fmask
If you mount your ntfs partition with default options, you may have different 'default file creation permission' with your linux partition. Sometimes, this makes nasty issues. For example, when you clone a git repository from a remote, your checked-out files and directories might have different permissions with the original ones.
Basically, for the newly created directories and files, linux assigns permission 777 for the directories and assigns permission 666 for the files. And umask (/etc/profile) is applied here. Default value of umask is 022(0022). So if you create a directory, it will have the default permission value 755. If it is a file, it's permission will be 644.
If you mount your ntfs partition with default options, umask, dmask, and fmask are all 0000. It implies that all the directories and files you created on the ntfs partition will have the permission 777. For the compatibility, you have to set:
umask= 0022
dmask=0000 (makes default directory permision 777)
fmask=0111 (makes default file permission 666)
Basically, for the newly created directories and files, linux assigns permission 777 for the directories and assigns permission 666 for the files. And umask (/etc/profile) is applied here. Default value of umask is 022(0022). So if you create a directory, it will have the default permission value 755. If it is a file, it's permission will be 644.
If you mount your ntfs partition with default options, umask, dmask, and fmask are all 0000. It implies that all the directories and files you created on the ntfs partition will have the permission 777. For the compatibility, you have to set:
umask= 0022
dmask=0000 (makes default directory permision 777)
fmask=0111 (makes default file permission 666)
Friday, March 4, 2011
AT91SAM7S-EK linux toolchain
SAM-BA
AT91SAM series, equipped with USB device capability, provide SAM-BA interface for easy downloading their firmware without JTAGs or any ISP tools. First, you may want ATMEL SAM-BA software for linux here. Depending on your linux settings (kernel maybe) you may need usbserial module also.
Just plug in your SAM board to the usb port and see what happens. lsusb shows how your linux box recognize your SAM board:
Bus 002 Device 023: ID 03eb:6124 Atmel Corp. ......
The vendor id 0x03eb is dedicated to Atmel. Then you can check how you linux box connect it to a device driver by running dmesg
[50341.865033] cdc-acm 2-5.2:1.0: ttyACM0: USB ACM device
If you find the message like above, you probably have newly created device in /dev:
crw-rw---- 1 root dialout 166, 0 2011-03-04 12:15 /dev/ttyACM0
Since SAM-BA uses /dev/ttyUSBx, you have to create a symbolic link:
$ sudo ln -s /dev/ttyACM0 /dev/ttyUSB0
Now, you are ready to fire up the SAM-BA
$ ./sam-ba
If the above senario is not the case for you, you may need usbserial kernel module, which is explained in the README.linux file of the SAM-BA linux software, i.e., you load the usbserial module:
$ sudo modprobe usbserial vendor=0x03eb product=0x6124
Then you will have /dev/ttyUSBx device when you plug in your SAM board.
AT91SAM series, equipped with USB device capability, provide SAM-BA interface for easy downloading their firmware without JTAGs or any ISP tools. First, you may want ATMEL SAM-BA software for linux here. Depending on your linux settings (kernel maybe) you may need usbserial module also.
Just plug in your SAM board to the usb port and see what happens. lsusb shows how your linux box recognize your SAM board:
Bus 002 Device 023: ID 03eb:6124 Atmel Corp. ......
The vendor id 0x03eb is dedicated to Atmel. Then you can check how you linux box connect it to a device driver by running dmesg
[50341.865033] cdc-acm 2-5.2:1.0: ttyACM0: USB ACM device
If you find the message like above, you probably have newly created device in /dev:
crw-rw---- 1 root dialout 166, 0 2011-03-04 12:15 /dev/ttyACM0
Since SAM-BA uses /dev/ttyUSBx, you have to create a symbolic link:
$ sudo ln -s /dev/ttyACM0 /dev/ttyUSB0
Now, you are ready to fire up the SAM-BA
$ ./sam-ba
If the above senario is not the case for you, you may need usbserial kernel module, which is explained in the README.linux file of the SAM-BA linux software, i.e., you load the usbserial module:
$ sudo modprobe usbserial vendor=0x03eb product=0x6124
Then you will have /dev/ttyUSBx device when you plug in your SAM board.
Thursday, March 3, 2011
EFM32STK linux toolchain
Sourcery G++ (Lite)
EFM32STK comes with CodeSourcery examples so you don't have to bother with constructing your own startup code and linker script. Install the CodeSourcery toolchain(bare metal), then all you have to do is changing a couple of lines in the Makefile
TOOLDIR = /your/CodeSourcery/toolchain/root
GCCVERSION = x.x.x
You can get your compiler version by firing up
$ arm-none-eabi-gcc --version
All the examples would be compiled without any complaints and ready to go. You can find your executable image files in the 'exe' subdirectory
Segger embedded J-Link
Thanks to the segger J-Link module embedded in the EFM32 STK board, you can use segger linux driver. Actually the STK itself could be utilized as a (standard) j-link tool. Unlike other vendor specific J-Link tools, there seems to be no limitation in using this. It might be used to other ARM devices (ARM7, ARM9/11, Cortex-M) as well as EFM32G devices. I will give it a try later. (UPDATE: It seems that the embedded J-Link does not work as a standard J-Link tool. You cannot even change the target chain from SWD to JTAG without help of EnergyCommander, which runs only on Windows, not to mention detecting a device on its JTAG connector) Anyway, grab the segger linux driver here and install it. Then you can flash your STK board with the J-Link Commander(just run start):
J-Link>exec device = EFM32G890F128
J-Link>loadbin /your/image/file/directory/xxx.bin 0x0
J-Link>r
J-Link>g
When is comes to debugging, you want execute gdb server with SWD option, because the efm32g processor is not on the JTAG chain but on the SWD,
$ JLinkGDBServer -if SWD
then, gdb
$ arm-none-eabi-gdb /your/exe/directory/xxx.out
Unfortunately, when you connect the jlinkgdbserver,
(gdb) target remote localhost:2331
you will get the following error:
Remote 'g' packet reply is too long: 00000000000....
This is an known issue (at least for JLink_Linux_V422 with arm-2010.09-51-arm-none-eabi). You have to wait until they release a fixed version of linux driver. So for now, without gdb compatibility EFM32STK provides quite limited usage on linux. To make things worse, segger windows j-link driver does not work on virtual machine (vmware player).
Flowgraph generation for the examples
By adding a few lines in the Makefile provided with the examples, you can easily generate a flowgraph of the source, i.e., you may want to add, at the end of the Makefile,
CFLOWFLAGS = -a --omit-arguments --omit-symbol-names
CPPFLAGS = --cpp='arm-none-eabi-cpp -E -D $(DEVICE)'
cflow: $(C_SRC) Makefile
cflow -o $(LST_DIR)/$(PROJECTNAME).cflow \
$(CFLOWFLAGS)$(INCLUDEPATHS) $(CPPFLAGS) $(C_SRC)
Then execute :
make cflow
will generate cflow outout in the lst directory. It is needless to mention that you have to install cflow first before using it.
EFM32STK comes with CodeSourcery examples so you don't have to bother with constructing your own startup code and linker script. Install the CodeSourcery toolchain(bare metal), then all you have to do is changing a couple of lines in the Makefile
TOOLDIR = /your/CodeSourcery/toolchain/root
GCCVERSION = x.x.x
You can get your compiler version by firing up
$ arm-none-eabi-gcc --version
All the examples would be compiled without any complaints and ready to go. You can find your executable image files in the 'exe' subdirectory
Segger embedded J-Link
Thanks to the segger J-Link module embedded in the EFM32 STK board, you can use segger linux driver. Actually the STK itself could be utilized as a (standard) j-link tool. Unlike other vendor specific J-Link tools, there seems to be no limitation in using this. It might be used to other ARM devices (ARM7, ARM9/11, Cortex-M) as well as EFM32G devices. I will give it a try later. (UPDATE: It seems that the embedded J-Link does not work as a standard J-Link tool. You cannot even change the target chain from SWD to JTAG without help of EnergyCommander, which runs only on Windows, not to mention detecting a device on its JTAG connector) Anyway, grab the segger linux driver here and install it. Then you can flash your STK board with the J-Link Commander(just run start):
J-Link>exec device = EFM32G890F128
J-Link>loadbin /your/image/file/directory/xxx.bin 0x0
J-Link>r
J-Link>g
When is comes to debugging, you want execute gdb server with SWD option, because the efm32g processor is not on the JTAG chain but on the SWD,
$ JLinkGDBServer -if SWD
then, gdb
$ arm-none-eabi-gdb /your/exe/directory/xxx.out
Unfortunately, when you connect the jlinkgdbserver,
(gdb) target remote localhost:2331
you will get the following error:
Remote 'g' packet reply is too long: 00000000000....
This is an known issue (at least for JLink_Linux_V422 with arm-2010.09-51-arm-none-eabi). You have to wait until they release a fixed version of linux driver. So for now, without gdb compatibility EFM32STK provides quite limited usage on linux. To make things worse, segger windows j-link driver does not work on virtual machine (vmware player).
Flowgraph generation for the examples
By adding a few lines in the Makefile provided with the examples, you can easily generate a flowgraph of the source, i.e., you may want to add, at the end of the Makefile,
CFLOWFLAGS = -a --omit-arguments --omit-symbol-names
CPPFLAGS = --cpp='arm-none-eabi-cpp -E -D $(DEVICE)'
cflow: $(C_SRC) Makefile
cflow -o $(LST_DIR)/$(PROJECTNAME).cflow \
$(CFLOWFLAGS)$(INCLUDEPATHS) $(CPPFLAGS) $(C_SRC)
Then execute :
make cflow
will generate cflow outout in the lst directory. It is needless to mention that you have to install cflow first before using it.
Subscribe to:
Posts (Atom)








