[Tutorial][Advanced]1.Programming Pokitto "offline" using EmBitz IDE


#1

Step 1: download and install EmBitz IDE

EmBitz is an “offline IDE” you can use to program Pokitto on your computer. That means you can make Pokitto-compatible binaries without the need to go to the mbed.com cloud tools.

EmBitz is an open-source IDE that is free, fast and relatively easy to learn. EmBitz was originally a fork of Code::Blocks. So if you have used the simulator, you will notice it works pretty much the same way.

Download from:
EmBitz

Step 2. get the PokittoLib library from Pokitto Github

Go to the Pokitto Github repository and either download as .zip file or “clone” with Git. You should learn to use Git instead of downloading as a zip, because then you are easily able to update your code to the latest version available on github.

Link to PokittoLib repository

Step 3. Start EmBitz and open “PokittoEmBitz.ebp”

Step 4. Check what is the “.elf” name of the target, and that “generate .hex” file option is ON

Now comes an important step about naming your target, so pay attention.

By default, the ARMGCC compilation produces an “.elf” image (ELF = Executable and Linkable Format)

By itself, the .elf file can be used with a hardware debugger to program Pokitto. But, if you do not use a hardware debugger, we need to generate a HEX file and convert that to the BIN format

This is why you need to know/set the name of the .elf file that is being output by the compiler,
and check that “Generate Hex file” option is turned on

To see the name of the .elf target, go to menu Project->Properties and select tab Build targets

Step 5. See that “post build steps” are correct

Remember we need to do something with the .elf file?

Our project has something calles “post build steps”. As the name implies, these are commands that are run after the compiler has made the .elf file

Go to menu Project->Build options and select tab “Pre/post build steps”

Now, verify that the name of the .elf file is the same as the name of the .hex file and the .bin file

Let’s look at the commands to understand what happens here:

arm-none-eabi-objcopy.exe -I ihex .\build\hello.hex -O binary .\build\hello.bin
.\build\lpcrc .\build\hello.bin

arm-none-eabi-objcopy is a tool provided along with EmBitz that I’ve copied to the /build/ directory for your convenience. This tool takes the .hex file and turns it into a .bin binary file

.\build\lpcrc is a tool provided by NXP. It injects the correct CRC checksum into the binary. Without this checksum, your program will never run!

Final step 6: compile, get binary and put it on Pokitto, reset

To compile your program, press the build button shown below.

Immediately on the right side of the “buld” button is the “rebuild” button.

Remember to rebuild completely if you change the project #defines or stuff inside My_settings.h. If you do not, the changes in graphics mode etc will not be done, because only a rebuild will recompile them

Your bin binary file will now appear in the /build folder. Put Pokitto in to USB mass storage mode. When in USB mass storage mode, the Pokitto appears as a storage device with the name CRP_DISABLED (this funny name only means that the device is not write-protected).

Finally delete existing “firmware.bin” and copy the new bin you just made into the Pokitto. Reset to run your program.

Happy coding!


Update on status of offline IDE
Compile error
#2

COOL COOL COOL COOL
:wink:

waiting for it


#3

Feedback, bugs, comments about missing information etc much appreciated.

So try it and let me know if you run into problems.


#4

Please:

try it
test it
give feedback

I need to know if you can make it work / what kind of problems (if any) you encounter.


#5

I just tried it, and mbed_config.h is missing from helloworld project?


#6

Oops. Just make an empty file with that name. There was nothing in it.


#7

It seems the project exporter from mbed to EmBitz has changed slightly, i.e. there are some incompatible LDFLAGS

I am fixing it now


#8

Now compiles and produces working code, repository updated


#9

Yes working :wink:

Install, clone the repository, open project and build that all.

The world need to know how is easy to code on POKITTO NOW !!!


#10

Excellent! Thanks for the feedback.

I will be adding more stuff (physics library, Arduboy2 library, examples) tomorrow


#11

How do we create new projects from scratch?


#12

Exactly the same way as with PokittoSim and Code::Blocks.

  • Go to project properties
  • duplicate target
  • give different name to .elf output file (and remember to do the same name change to project->build options->post build steps)

#13

hmmmm, I muddles through before you answered.
I created a new project from the hello world build target. However I’m getting the following error…

Creating Hex-file.
c:/program files (x86)/embitz/1.11/share/em_armgcc/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv6-m\libc_n.a(lib_a-nano-svfprintf.o): In function `__ssputs_r':
nano-vfprintf.c:(.text.__ssputs_r+0x46): undefined reference to `__wrap__malloc_r'
nano-vfprintf.c:(.text.__ssputs_r+0x68): undefined reference to `__wrap__realloc_r'
c:/program files (x86)/embitz/1.11/share/em_armgcc/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv6-m\libc_n.a(lib_a-nano-svfprintf.o): In function `_svfiprintf_r':
nano-vfprintf.c:(.text._svfprintf_r+0x1a): undefined reference to `__wrap__malloc_r'
collect2.exe: error: ld returned 1 exit status
arm-none-eabi-objcopy.exe: '.\build\sensitive.elf': No such file
Process terminated with status 1 (0 minutes, 33 seconds)
1 errors, 53 warnings (0 minutes, 33 seconds)

#14

This is due to LDFLAGS that are relevant to mbedOS but not the vanilla mbed we are using

Go to Linker defines, take out the malloc/free stuff that looks like it is related. Try to compile.

100% sure that is the issue


#15

Excellent, that seems to have done it!
Still no sound though…


#16

Yep, same situation in all programs. I think I may have accidentally left some debug disable somewhere (its the library, not your code) when I was looking at some issues with the online compiler.

I’m going to look at that with HW debugging later today, it is something really dumb. I’m sure of that.

But program runs and compiles otherwise?


#17

Yes, everything else seems OK.


#18

What are the steps involved in creating a new project from the Hello World target? If you don’t mind sharing :slight_smile:


#19

In file menu on Code::Blocks;
Project->Properties-> Opens Project/targets options.

In that window switch to the Build targets tab.

Make sure HelloWorld is selected, duplicate HelloWorld. Then you can rename the copy to whatever you like :slight_smile:


#20

@Gaveno

Also remember to make a new folder for your project, with its own main.cpp (or similar, where the main function is in) and My_settings.h that specifies the project settings for that target. Then, in the project->properties point the compiler search directory to this folder so that the compiler is reading the right My_settings.h

In this way you will be able to easily make a mbed online version of your project by copying over the project source files and My_settings.h

Finally, check that the list of .cpp files being compiled by your project now includes your new main.cpp and excludes the original HelloWorld.cpp. Otherwise you will have two main functions!

Ask for more info if you are struggling to understand