EmbLin
 
xvTouch
 
sMultiTA
  Rabbit Dlr
 
Java Fun
|
  DownLoad & Run     by Luc Hermans
smultita at gmail.com |
Bootp, TFTP & Flash upgrade on a Rabbit 
Last update 15 Apr 2004
This document describes howto Download a program via DHCP/BOOTP/TFPT and run this program on a Rabbit RCM2200/3700
Optional the downloaded program can be written to Flash (your firmware upgrade)
Content
This is what I needed to easy updgrade my firmware in the field. Maybe it's usefull 4U2.
The software is tested on a Rabbit RCM2200, RCM2250 and RCM3700 with Dynamic_C_7.21SE, DC_8.30 and DC_8_51.
It's different from DLM that it does NOT need any (A18) hardware modification.
However it is less robust. (crashes during flash write)
DLR can also download your program to RAM an RUN it.
In My first Rabbit project I needed flash upgrade but did not know how to. DLM was not an option (because of the hardware modification). By testing TFTP, examining Rabbit Memory Management I figured out how to download and run a program in RAM. If I could do this I was able to run any program, including a firmware upgrade utility. Because of the time pressure of the project, I delayed the development of this utitly, but implemented DLR for ram only. In the time that the customer was testing the our device, I modified DLR to write to flash. After I solved some
customer reported bugs, I send him a mail with the upgrade utitlity (Pumpkin TFPT + download.bin + program.bin) attached in a ZIP file (214 KB) and our customer upgraded the firmware (a couple of times) until the final release.
WARNING:
This PROGRAM is provided AS A SAMPLE ONLY in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It could overwrite your SysIDBlock (only if you download programs > 220KB)
- Build your application program
Set the compiler option Code and Bios to RAM, and compile your popular program to bin file.
(in DC 8.xx under Project_Options, Compiler: set 'Code and BIOS in RAM' and 'Compile defined target config to .bin file' then press F5 to compile)
Rename this file to download.bin. Download.bin can be upto +/- 100KB in a 128KB RAM system
- Program your Rabbit
Use the RFU utility to program your flash with DlrBootp.bin
- Setup TFTP server
Use your favorite TFTP server or download
TFPTD32 =(TFTP + BOOTP + DHCP) or
PumpKin TFTP
Copy the file download.bin to the TFTP root directory and give (all users) read access to this file.
- Setup DHCP/BOOTP server
If you have a DHCP/Bootp server set the Boot Server Host Name to the IP address of the system where the TFTP server is installed.
Set the BootFile Name to /download.bin.
- No BOOTP server ?
DLR also works with DHCP/TFTP. Then TFTP server must be the same as the DHCP server and
the boot file name is fixed download.bin. Download the worlds smallest DHCP server from
Uwe A. Ruttkamp DHCP
and configure the dhcpsrv.ini file with the [MAC address] of your Rabbit.
- Run your download.bin
Reset your Rabbit processor
RABBIT |   | DHCP/TFTP server |
  | ---> DHCP req |   |
  | <--- YourIP, myIP, [yourBootFile, tftpIP] | DHCP server |
  | ---> TFPT get DOWNLOAD.BIN |   |
save in RAM | <--- DOWNLOAD.BIN | TFTP server |
run DOWNLOAD.BIN from RAM |   | next |
- Build your application program
Set the compiler option Code and Bios to FLASH, and compile your popular program to bin file.
Rename this file to program.bin. Program.bin can be upto +/- 220KB. (to big files will overwrite SysIDBlock).
- Setup TFTP server
Copy the file program.bin to the TFTP root directory.
Rename the file DlrFlash.bin to download.bin and put it in the TFTP root dir.
- Flash Write and Run your program.bin
Reset your Rabbit processor
RABBIT |   | DHCP/TFTP server |
DOWNLOAD is now running from RAM |   |   |
  | ---> DHCP req |   |
  | <--- YourIP, myIP | DHCP server |
  | ---> TFPT get PROGRAM.BIN |   |
save in FLASH | <--- PROGRAM.BIN | TFTP server |
run PROGRAM.BIN from FLASH |   |   |
- To make DlrBootp just compile DLR.C to Flash ...
- To make DlrFlash just compile DLR.C to Ram ...
- In the MAIN_APP implement a downloader (DlrBootP)
- The MAIN_APP can download another PROGRAM to the beginning of RAM (this program was compiled to RAM)
- And run this program in RAM (map RAM to bank0 and jp 0x0000)
- Because this is my firmware upgrade utitly (DlrFlash) the program downloads my new MAIN_APP and upgrades the FLASH
- Map FLASH to bank0 an runs the upgraded MAIN_APP
- Static IP address (no DHCP, only TFTP)
This is how I use this stuff. The IP address of the rabbit can be configured and is saved in the UserBlock
or can be patched in the bin files using a hex editor.
//-- use DLR.C as a lib (uses only 180 bytes, excluding TFTP about 2KB)
#define DLR_LIB
#use "DLR.C"
//... main stuff of my project
//-- Upgrade Firmware, initiated by a user action ...
dlr_tftp( srv_ip_addr, FILE_2_DOWNLOAD, gWdog);
- Use TCP or a Serial connection
Write your own firmware upgrade utility (use DLR.C as example). Test it with Dynamic C IDE (compiling to RAM)
and, if it works fine, make your own DOWNLOAD.BIN file. Then add the following code to your project.
#ximport DOWNLOAD.BIN download_bin
#define DLR_LIB
#use "DLR.C"
//... main stuff of my project
//-- Upgrade Firmware, initiated by some event, command received, ...
root2xmem( 0x80000UL, download_bin, size) //-- or xmem2xmem
dlr_run(); //-- only 20 bytes
- Run different programs from one flash
Use the #ximport to include different programs in your flash. Depending on some conditions select the program to run.
- Put a TFTP SERVER in the Rabbit
And put this in your network along with his friends, who will download and run the program located in this tini server.
- Insert RUN command in ZCONSOLE.C
The source DLR.C (V1.02) can be downloaded here.
It is only 200 lines of code but has cost me lots of struggling the DC sources and compiler.
If you have some improvements, bugfixes, tips, ... let me know.
If you find this usefull can drop me an Email and attach 10 Euro, 10 Dollar or an SD Flash_card.
Thanks,
Luc
Related Links
|