{"id":288,"date":"2011-06-03T12:57:25","date_gmt":"2011-06-03T19:57:25","guid":{"rendered":"http:\/\/..\/?p=288"},"modified":"2011-06-03T12:57:25","modified_gmt":"2011-06-03T19:57:25","slug":"bootloader-for-the-lpc2378-stk","status":"publish","type":"post","link":"https:\/\/blog.engine12.com\/?p=288","title":{"rendered":"Bootloader for the LPC2378-STK"},"content":{"rendered":"<p>One of my dev boards is an LPC2378-STK.\u00a0 It&#8217;s a fun board but, the JTAG programming interface for it is dreadfully slow.\u00a0 I messed around a bit and learned that programming the flash memory with the iap interface was the way to go.\u00a0 It was taking around 18 secs to write a sector with the isp interface, while almost instant when using iap.\u00a0 In order to make use of the iap programming interface a secondary bootloader needs to be present in flash.<\/p>\n<h2><a href=\"..\/wp-content\/uploads\/2011\/06\/USB_Bootloader.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-315 alignleft\" src=\"..\/wp-content\/uploads\/2011\/06\/USB_Bootloader-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.engine12.com\/wp-content\/uploads\/2011\/06\/USB_Bootloader-300x225.jpg 300w, https:\/\/blog.engine12.com\/wp-content\/uploads\/2011\/06\/USB_Bootloader.jpg 320w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>SD Secondary Bootloader<\/h2>\n<p>There&#8217;s a number of choices for implementing a secondary bootloader on the LPC2378-STK, ethernet, usb, and SD\/MMC are available.\u00a0 I chose the SD\/MMC route.\u00a0 The board also includes an LCD, and joystick.\u00a0 I made use of these and added functionality to select from a list, the program that I want to load into flash.\u00a0 The list is displayed on the boards LCD and represents the programs stored on the SD card.<\/p>\n<p>&nbsp;<\/p>\n<h2>USB Mass Storage<\/h2>\n<p>To populate the SD card with the programs, I set up the USB to act as a mass storage device.\u00a0 The board shows up automatically under Linux and Windows.\u00a0 I used the <a href=\"http:\/\/sourceforge.net\/projects\/lpcusb\/\">LPC_USB<\/a> project to get started and coupled the result with <a href=\"http:\/\/elm-chan.org\/fsw\/ff\/00index_e.html\">Chans FAT<\/a> for file system functions.\u00a0 I found good examples for the SD\/MMC interface from <a href=\"http:\/\/gandalf.arubi.uni-kl.de\/avr_projects\/arm_projects\/\">Martin Thomas<\/a>.\u00a0 For some reason I was using Windows at the time&#8230;\u00a0 anyway, the JTAG I was using didn&#8217;t like the board getting reset.\u00a0 I solved the problem with a bat file and a gdb script that assist with transferring the image to the SD card and resetting the JTAG.\u00a0 They are included in the source package.\u00a0 If your host is Linux, I&#8217;ll assume you can write your own script.\u00a0 Note, everything works *much* better on Linux, even inside a VM.<\/p>\n<p>&nbsp;<\/p>\n<h2><a href=\"..\/wp-content\/uploads\/2011\/06\/bootloader1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignright size-medium wp-image-309\" src=\"..\/wp-content\/uploads\/2011\/06\/bootloader1-211x300.png\" alt=\"\" width=\"211\" height=\"300\" srcset=\"https:\/\/blog.engine12.com\/wp-content\/uploads\/2011\/06\/bootloader1-211x300.png 211w, https:\/\/blog.engine12.com\/wp-content\/uploads\/2011\/06\/bootloader1.png 411w\" sizes=\"(max-width: 211px) 100vw, 211px\" \/><\/a>Linking<\/h2>\n<p>The object code must be linked with respect to its location in flash.\u00a0 Additionally the exception vectors need to be loaded into high memory in the startup script.\u00a0 The ReadMe file in the <a href=\"http:\/\/engine12.com\/files\/lpc2378-stk\/USB_Bootloader.zip\">source package<\/a> includes a linker script for use with the <a href=\"..\/?p=59\">GNU toolchain<\/a> and startup assembly for building a project that can be launched with the bootloader.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/engine12.com\/files\/lpc2378-stk\/USB_Bootloader.zip\">http:\/\/engine12.com\/files\/lpc2378-stk\/USB_Bootloader.zip<\/a><\/p>\n<p><a href=\"http:\/\/gandalf.arubi.uni-kl.de\/avr_projects\/arm_projects\/\">http:\/\/gandalf.arubi.uni-kl.de\/avr_projects\/arm_projects\/<\/a><\/p>\n<p><a href=\"http:\/\/elm-chan.org\/fsw\/ff\/00index_e.html\">http:\/\/elm-chan.org\/fsw\/ff\/00index_e.html<\/a><\/p>\n<p><a href=\"http:\/\/sourceforge.net\/projects\/lpcusb\/\">http:\/\/sourceforge.net\/projects\/lpcusb\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of my dev boards is an LPC2378-STK.\u00a0 It&#8217;s a fun board but, the JTAG programming interface for it is dreadfully slow.\u00a0 I messed around a bit and learned that programming the flash memory with the iap interface was the way to go.\u00a0 It was taking around 18 secs to write a sector with the <a href='https:\/\/blog.engine12.com\/?p=288'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/posts\/288"}],"collection":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288"}],"version-history":[{"count":0,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=\/wp\/v2\/posts\/288\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.engine12.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}