SourceForge has been redesigned. Learn more.

Flashing to the NXT

  • anne

    anne - 2007-12-27

    Dear developers,

    Which tool do you use to flash the code to the NXT? I am using fwflash from libnxt ( I am able to flash the normal Lego firmware or e.g. John Hansen's firmware (NXT_JCH_1.5.a79 in\).

    I run ./fwflash HelloWorld_samba_ram.bin

    Is there the appropriate binary file? I see also a HelloWorld_rom.bin file, that is almost the same, just some minor differences. Why is this called a "rom" file? And what is the "HelloWorld_ram.elf" file, and why is there no stripped binary variant of that file?

    Thanks a lot in advance for helping me out!

    Kind regards,


    • anne

      anne - 2007-12-27

      By the way, it is possible to upload the binary to the ARM, however, the NXT does just not stop making the "SAMBA bootloader" ticking sounds.

      And I am afraid to erase the bootloader itself (according to the AT91SAM7S datasheets it is on the ROM part, about which I don't know if it is actually read-only or some EEPROM variant). Nor do I know if I need to reprogram the Atmel AVR controller on-board too perhaps.

      And I suppose that there should be a hello world message on the screen. :-)

      • Jose Vasconcellos

        Actually, SAMBA is part of the AT91SAM7S boot ROM which is separate from the 256KiB of FLASH. So, there's no danger of corrupting this; you can always get to SAMBA by asserting the TST pin on power-on. The only issue would be if the security bit is set.

        You may want to read about the capabilities of SAMBA from the Atmel documentation. There's additional discussions at

        • anne

          anne - 2008-01-03

          Thanks Jose! That takes some worries away. :-) Can you also explain to me what the different binaries are? Or can you refer me to the proper person? Kind Thanks in advance!

          • Jose Vasconcellos

            The "ram" image is downloaded to the 64KiB of RAM and executed from there if your program is small enough to fit in this space. The advantage is that no FLASH programming is necessary and more importantly it's much easier to debug. If the program handles interrupts then you have to make sure that RAM (location 0x200000) is mapped to location 0 so that the interrupt vectors can be in RAM. Of course, after a reset the program will be lost. The alternative is the "rom" version which is written to FLASH. After reset, the FLASH (location 0x100000) is mapped to location 0. You'll want to download the CPU documentation ( to better understand the boot sequence the the CPU peripherals.

            • anne

              anne - 2008-01-03

              Hey Jose, Thanks! You posted just at the same time as myself. I hope your answer will me guide me to the solution. ;-) Thanks! Anne

              • anne

                anne - 2008-01-04

                Thanks Jose!

                I quickly squinted ;-) through the manual once. It helps always, although especially the part about the memory mapping I find hard to understand (Figure 8-1). Why is there as much as 1 MB reserved for "Flash before Remap" or "SRAM after Remap"? And what does those terms exactly mean?

                I was also looking through the .map files. It makes also some things somewhat clearer. E.g. in the memory configuration it is stated quite explicitly that the only binary that writes something to ROM is the "HelloWorld_rom.bin" file. :-) I don't know what the RAM vector is from 20000-20040 e.g. and there is a lot of other stuff I don't understand. Is there such "meta-information" available online? Or is it only obtainable from a text book about the ARM architecture?

                Anyway, I managed to download it to the device in flash:
                  sudo $lejos_nxj/src/libnxt/fwflash $lejos_osek/samples/helloworld/HelloWorld_rom.bin

                Now I can start programming neural nets. :-)

                Kind regards!


          • anne

            anne - 2008-01-03

            Dear lejos osek people! :-)

            I've been fooling around with the files. Encountered a lot of problems, such as not having by default mhard-float/msoft-float etc.  MULTILIB_OPTIONS enabled in the configuration file gcc-4.1.1/gcc/config/arm/t-arm-elf of my cross-compiler.

            I can use the "runc" application to run the helloworld:

              sudo $lejos_nxj/src/libnxt/runc $lejos_osek/samples/helloworld/HelloWorld_samba_ram.bin
              File size is 14528
              NXT device in reset mode located and opened.
              Starting C program now...

            This works until I turn off the brick.

            Like I mentioned before I want to use the "fwflash" application to program it on the appropriate place in the brick.

            As a side remark, I am also able to use "nxjflash" that needs two binaries, one for the menu, one for the virtual machine. This is - of course - not part of Lejos OSEK itself, but of its Java successor, but it uses the same C code written by Anderson.

            So, I am still dumbfounded about the fact that flashing "HelloWorld_samba_ram.bin" with fwflash doesn't work and the brick only starts to tick without displaying anything.

            I'd love to receive some suggestions or corrections. :-) Thanks in advance!


Log in to post a comment.