Author Topic: boot loader support in LPC2388  (Read 25638 times)

Offline Manish

  • Newbie
  • *
  • Posts: 23
    • View Profile
boot loader support in LPC2388
« on: September 26, 2009, 10:34:49 AM »

 Hi All,
I am new for utasker. can anybody help for how to downloading bootloader and application code in to lpc controller. I am compiling code using Keil and till downloading code using Flash Magic. what kind of utility required for downloading bootload code and application code.

Thanks
Manish


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: boot loader support in LPC2388
« Reply #1 on: September 26, 2009, 11:56:41 PM »
Hi Manish

When you have compiled the boot loader and an application (don't forget to compile the application for "bare-minimum" target) you will have two files which need to be merged together to create a single binary file. This then is converted to a hex file for compatibility with FlashMagic, with which it is downloaded as one single code.

In the target directory for your compiler build you will find a bat file (eg. Build_LPC23XX.bat in \Applications\uTaskerV1.4\GNU_LPC23XX if you are using GNU) which will perform the conversion and generation of the downloadable file, as well as a file to copy via HTTP (once the first application is installed and working).

A typical content of this bat file includes

uTaskerCombine "../../uTaskerBoot/GNU_LPC23XX/uTasker_boot.bin" uTaskerV1.4_BM.bin 0x1000 uTaskerBM.bin
arm-none-eabi-objcopy --input-target=binary --output-target=ihex uTaskerBM.bin uTaskerV1.4_BM.hex
uTaskerConvert.exe uTaskerV1.4_BM.bin z_Upload.bin -0x72ca -88263b6290a1


Note that the GCC objcopy is being used to convert to hex. uTaskerConvert.exe could also be used to do this but presently only works up to 64k files, which explains why the objcopy is being used to be on the safe side (this is something on the list of things to do but seems to have taken very low priority...). In some project targets the hex step may be missing but the conversion can still be achieved by using (adding) the objcopy step.

Regards

Mark






Offline Manish

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: boot loader support in LPC2388
« Reply #2 on: October 07, 2009, 05:56:28 AM »
hi Mark,

 I have two code in uTasker version1.4, one is Bootloader code and onther is Application code.
 As per your reply  I had compiled bootloader code and application code in Keil compiler. but when I was trying to combine both code's hex file it cant generate bin file. When I try to convert from bin to hex, it cant convert also. so please help regarding this.

And one problem to in Application programe I had seen that there is no support to download file new application file in FTP. so can you tell me how can i will do?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: boot loader support in LPC2388
« Reply #3 on: October 07, 2009, 03:21:07 PM »
Hi Manish

Please can you tell me which outputs Keil is generating? Also how you are trying to combine them?
Have you tried the GNU conversion utility or are you trying something in the Keil environment?

If you don't make any progress please send me the two files that you have generated so that I can see that they are suitable and then try to convert them.

When uploading new software via FTP there is no application support required. The file must have the correct name so that it is uploaded to teh correct location (z_Upload.bin is usually used in the LPC23XX project since it is the last file in the file system space). After the upload via FTP (using DOS or any other suitable FTP client) the new software will be copied to program flash after the next reset of the board. When uploading via HTTP the reset is automated but not when copied via FTP since FTP doesn't have an interface to the application - it works purely with the uFileSystem.

regards

Mark


Offline Manish

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: boot loader support in LPC2388
« Reply #4 on: October 08, 2009, 06:07:18 AM »
Good morning Mark,

Keil Uvision generate Hex file as well bin file. I have attach two individual compiled hex file and bin file along with uv setting. Please check it and if it has any problem then suggest me.

I hadn't problem with generating two file. It is generated from uTaksercombile.exe.

 How can i combine bootloader and application bin or Hex file? I have clear with uploading new bin file, but I have at initially. so please help regarding this.

Thanks
Manish Dabhi

Offline Manish

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: boot loader support in LPC2388
« Reply #5 on: October 08, 2009, 06:11:33 AM »
Good morning Mark,

I have problem with uploading with more then two so ,i have attached file in this Post.

Thanks
Manish Dabhi

Offline Manish

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: boot loader support in LPC2388
« Reply #6 on: October 08, 2009, 06:12:45 AM »
Good morning Mark,

I have problem with uploading with more then two so ,i have attached file in this Post.

Thanks
Manish Dabhi

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: boot loader support in LPC2388
« Reply #7 on: October 14, 2009, 01:24:08 AM »
Hi Manish

I finally had the opportunity to study this.

Basically you have a binary file uTaskerBM.bin, which is a merged file consisting of the boot loader (from address 0x0000...0x0a8b) and the application (linked to start at address 0x1000 and finishing at 0x13dcb) - between the two (from 0x0a8c...0x0fff) are 0xff (padding). This is the binary file that can be downloaded with some tools.

You however would like this in Intel hex format so that you can download it using FlashMagic (which only accepts Intel Hex input). The binary file can be converted using objcopy.exe from the GCC tool chain using the following command:

arm-none-eabi-objcopy --input-target=binary --output-target=ihex uTaskerBM.bin uTaskerV1.4_BM.hex

This however assumes that the tool chain is installed (eg. from CodeSourcery). If it isn't you may find that there is also an equivalent utility in the uVision3 tool chain - I don't know uVision that well so don't know what it would be called.

However the uTaskerCombine utility, which was used to generate the binary file, can also generate Intel Hex outputs:

The following is the standard use, as in you Bat file:

uTaskerCombine "../../uTaskerBoot/uVision3_LPC23xx/ObjectFiles/uTaskerBoot.bin" "ObjectFiles\uTaskerV1_4.bin" 0x1000 uTaskerBM.bin

To generate a HEX output an additional file can be added:
uTaskerCombine "../../uTaskerBoot/uVision3_LPC23xx/ObjectFiles/uTaskerBoot.bin" "ObjectFiles\uTaskerV1_4.bin" 0x1000 uTaskerBM.bin uTaskerBM.hex

However this is not used due to a present restriction - it only generates Intel Hex format up to 64k and not extended Intel HEX, so limits the output to 64k - smaller than the demo project output. The workaround for larger outputs was thus to use objcopy...

So I took a look at uTaskerCombine to see whether it would be difficult to extend the Intel HEX output to include the extended format and thus full compatibility. It turned out that this was not that hard so I have created a uTaskerCombine V1.1 (to request the version use "uTaskerCombine -v" - note however the the V1.0 will not answer to this though).

This can then use the command as above (with extra argument uTaskerBM.hex).

I successfully tested this on the Olimex LPC-2378-STK but did note that the projects (application and boot loader) need to be set up correctly to match, which involves the following steps:
1) Ensure that the define _336K_FILE_SYSTEM_SPACE is enabled (eg. add to config.h) so that the larger file system is used (smaller is possible but won't match the boot loader configuration as it is).
2) In Build_LPC23XX.bat (or however it is named in the particular application) ensure that the magic number and key match with those in the boot loader.
3) I had no problems using the boot loader from the uVision project, the IAR project and the Rowley crossworks project, but found that the GCC project is not ready for this (it's make file is not complete in the present version). I did in fact correct this but still couldn't get it to run since it was crashing when configuring the PLL when debugging and I couldn't get any debuggers to behave sensibly in this code area to sort it out; what is confusing is that the GCC project and the Rowley project (also GCC based) use the same files and settings but the stand-alone GCC boot loader won't behave at the moment - this will need to be looked at again, but for the moment the new uTaskerConvert program may prove to be helpful for all other cases.

Regards

Mark

PS. There are two further notes about using this project setup on the LPC2XXX:
1) Use the web pages in \Applications\uTaskerV1.4\WebPages\WebPagesLPC23xx\WebPagesUpload to match the larger file system setup.
2) If there is a file in the upload area (eg, a previous z.BIN that isn't recognised by the loader and so is not deleted) it is necessary to delete it manually (eg. via FTP). The reason for this is due to the large FLASH granularity of the LPC2XXX requiring (usually) use of the sub-file system. Since z.BIN is a sub-file in this setup it is not automatically deleted when a further file is uploaded to its space and may cause the uploaded file to be corrupted if not first deleted.
« Last Edit: October 14, 2009, 01:29:22 AM by mark »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: boot loader support in LPC2388
« Reply #8 on: October 14, 2009, 03:53:42 PM »
Hi All

Sorry, I made a mistake when uploading the new version of uTaskerCombine.exe (in previous post). This is the original version and not V1.1 !!

Here is the correct version V1.1.

Regards

Mark


Offline saurabh

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: boot loader support in LPC2388
« Reply #9 on: October 15, 2009, 03:48:24 PM »
 Good morning Mark,

 we have generated hex of combining booy loader and application code and downlaod in board and after that it is running successfully, but after that when we are duming new code(z.bin developed using convert.exe) it will not generated and gives error (cant create). so I have attach my application.bin please check it and reply me if their have any problem.

Offline saurabh

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: boot loader support in LPC2388
« Reply #10 on: October 15, 2009, 03:52:52 PM »
Good morning Mark,

   I have generated bootloader and applciation combined hex file and it is running properly. but after that when we are generating new z.bin using convert.exe with magic no it  is not generating and gives error . I have attach my application file please check it and give me reply what problem there. we are only wait for your reply.

Thank you

Manish Dabhi


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: boot loader support in LPC2388
« Reply #11 on: October 15, 2009, 08:53:22 PM »
Hi Manish

I could convert the file so I don't think that it has anything to do with the bin file that you have.


The command to convert the file is in the bat file - uTaskerConvert.exe "ObjectFiles\uTaskerV1_4.bin" z_Upload.bin -0x72ca -88263b6290a1

This assumes that it is being executed in \Applications\uTaskerV1.4\uVision3_LPC23xx

If the input file can not be opened you get the error message - "Input file could not be found. Terminating"
If you get an error that it can't create a file it may be that the output directory is protected in some way. Since it also overwrites any existing z_Upload.bin files this may fail if an existing file is set to read-only (for example). Try changing the name of the output file in this case.

Regards

Mark


Offline Manish

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: boot loader support in LPC2388
« Reply #12 on: October 16, 2009, 11:43:53 AM »
Good morning Mark,



  We have done z_upload.bin as per you have suggested but still new application not uploading because we are checking file in z.bin file in dir using FTP promp it is display M.BIN so we cant understood how this happen?. we have also seen that there is bootloader for USB but not for FTP ot webbased. so can you explain me why this?
 
 if we want open M.BIN file , read those file and uploading using fnDownload(Debug.c)  function. is this possible?.

Thank you
Manish Dabhi

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: boot loader support in LPC2388
« Reply #13 on: October 16, 2009, 01:55:18 PM »
Hi Manish

It sounds as though you are not using the correct configuration for a project with upload support:

1) You need to configure for 336k file system size (otherwise it is not large enough) by adding _336K_FILE_SYSTEM_SPACE  (see also http://www.utasker.com/forum/index.php?topic=699.msg3120#msg3120 for a step-by-step list of settings)
2) Load the correct web pages (\Applications\uTaskerV1.4\WebPages\WebPagesLPC23xx\WebPagesUpload) - this will ensure that the upload goes to the correct location (the web pages in \Applications\uTaskerV1.4\WebPages\WebPagesLPC23xx\WebPagesDemo are not designed to support SW uploads and will send data to a different location.


The upload can be performed using FTP (after the copy the file will be visible "DIR") and after a reset (manual) it will load the new software.
The upload can also be performed on the admin web page. In this case the reset is automatic.

The LPC2xxx project doesn't support USB at the moment and so USB uploading is not possible (it is presently only possible in the M522XX and SAM7X projects).

Regards

Mark

Offline Manish

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: boot loader support in LPC2388
« Reply #14 on: October 21, 2009, 10:22:34 AM »
Good morning Mark,
 
 Thank for giving a full support for solving Boot loader code. we have done boot loader support in our exsting board.

Thanks
Manish Dabhi (MD)