blob: 0fcdba27d46892aeb801f86558504bdd49e56a68 [file] [log] [blame]
wdenk656658d2004-10-10 22:16:06 +00001#!/bin/sh
2
3# This script converts binary files (u-boot.bin) into so called
4# bootstrap records that are accepted by Motorola's MC9328MX1/L
5# (a.k.a. DragaonBall i.MX) in "Bootstrap Mode"
Wolfgang Denk93e14592013-10-04 17:43:24 +02006#
wdenk656658d2004-10-10 22:16:06 +00007# The code for the SynchFlash programming routines is taken from
8# Bootloader\Bin\SyncFlash\programBoot_b.txt contained in
Wolfgang Denk93e14592013-10-04 17:43:24 +02009# Motorolas LINUX_BSP_0_3_8.tar.gz
10#
wdenk656658d2004-10-10 22:16:06 +000011# The script could easily extended for AMD flash routines.
12#
13# 2004-06-23 - steven.scholz@imc-berlin.de
14
15#################################################################################
16# From the posting to the U-Boot-Users mailing list, 23 Jun 2004:
17# ===============================================================
Wolfgang Denk93e14592013-10-04 17:43:24 +020018# I just hacked a simple script that converts u-boot.bin into a text file
19# containg processor init code, SynchFlash programming code and U-Boot data in
wdenk656658d2004-10-10 22:16:06 +000020# form of so called b-records.
Wolfgang Denk93e14592013-10-04 17:43:24 +020021#
22# This can be used to programm U-Boot into (Synch)Flash using the Bootstrap
wdenk656658d2004-10-10 22:16:06 +000023# Mode of the MC9328MX1/L
Wolfgang Denk93e14592013-10-04 17:43:24 +020024#
wdenk656658d2004-10-10 22:16:06 +000025# 0AFE1F3410202E2E2E000000002073756363656564/
26# 0AFE1F44102E0A0000206661696C656420210A0000/
27# 0AFE100000
28# ...
29# MX1ADS Sync-flash Programming Utility v0.5 2002/08/21
Wolfgang Denk93e14592013-10-04 17:43:24 +020030#
wdenk656658d2004-10-10 22:16:06 +000031# Source address (stored in 0x0AFE0000): 0x0A000000
32# Target address (stored in 0x0AFE0004): 0x0C000000
33# Size (stored in 0x0AFE0008): 0x0001A320
Wolfgang Denk93e14592013-10-04 17:43:24 +020034#
wdenk656658d2004-10-10 22:16:06 +000035# Press any key to start programming ...
36# Erasing ...
37# Blank checking ...
38# Programming ...
39# Verifying flash ... succeed.
Wolfgang Denk93e14592013-10-04 17:43:24 +020040#
wdenk656658d2004-10-10 22:16:06 +000041# Programming finished.
Wolfgang Denk93e14592013-10-04 17:43:24 +020042#
wdenk656658d2004-10-10 22:16:06 +000043# So no need for a BDI2000 anymore... ;-)
Wolfgang Denk93e14592013-10-04 17:43:24 +020044#
45# This is working on my MX1ADS eval board. Hope this could be useful for
wdenk656658d2004-10-10 22:16:06 +000046# someone.
47#################################################################################
48
49if [ "$#" -lt 1 -o "$#" -gt 2 ] ; then
50 echo "Usage: $0 infile [outfile]" >&2
51 echo " $0 u-boot.bin [u-boot.brec]" >&2
52 exit 1
53fi
54
55if [ "$#" -ge 1 ] ; then
56 INFILE=$1
57fi
58
59if [ ! -f $INFILE ] ; then
60 echo "Error: file '$INFILE' does not exist." >&2
61 exit 1
62fi
63
64FILESIZE=`filesize $INFILE`
65
66output_init()
67{
68echo "\
69********************************************
70* Initialize I/O Pad Driving Strength *
71********************************************
720021B80CC4000003AB
73********************************************
74* Initialize SDRAM *
75********************************************
7600221000C492120200 ; pre-charge command
7708200000E4 ; special read
78
7900221000C4A2120200 ; auto-refresh command
8008000000E4 ; 8 special read
8108000000E4 ; 8 special read
8208000000E4 ; 8 special read
8308000000E4 ; 8 special read
8408000000E4 ; 8 special read
8508000000E4 ; 8 special read
8608000000E4 ; 8 special read
8708000000E4 ; 8 special read
88
8900221000C4B2120200 ; set mode register
9008111800E4 ; special read
91
9200221000C482124200 ; set normal mode
93 "
94}
95
96output_uboot()
97{
98echo "\
99********************************************
100* U-Boot image as bootstrap records *
101* will be stored in SDRAM at 0x0A000000 *
102********************************************
103 "
104
105cat $INFILE | \
106hexdump -v -e "\"0A0%05.5_ax10\" 16/1 \"%02x\"\"\r\n\"" | \
107tr [:lower:] [:upper:]
108}
109
110output_flashprog()
111{
112echo "\
113********************************************
114* Address of arguments to flashProg *
115* ---------------------------------------- *
116* Source : 0x0A000000 *
117* Destination : 0x0C000000 * "
118
119# get the real size of the U-Boot image
120printf "* Size : 0x%08X *\r\n" $FILESIZE
121printf "********************************************\r\n"
122printf "0AFE0000CC0A0000000C000000%08X\r\n" $FILESIZE
123
124#;0AFE0000CC0A0000000C00000000006000
125
126echo "\
127********************************************
128* Flash Program *
129********************************************
1300AFE10001008D09FE5AC0000EA00F0A0E1A42DFE0A
1310AFE1010100080FE0A0DC0A0E100D82DE904B04CE2
1320AFE1020109820A0E318309FE5003093E5033082E0
1330AFE103010003093E5013003E2FF3003E20300A0E1
1340AFE10401000A81BE9A01DFE0A0DC0A0E100D82DE9
1350AFE10501004B04CE204D04DE20030A0E10D304BE5
1360AFE1060109820A0E330309FE5003093E5033082E0
1370AFE107010003093E5013903E2000053E3F7FFFF0A
1380AFE1080104020A0E310309FE5003093E5032082E0
1390AFE1090100D305BE5003082E500A81BE9A01DFE0A
1400AFE10A0100DC0A0E100D82DE904B04CE20000A0E1
1410AFE10B010D7FFFFEB0030A0E1FF3003E2000053E3
1420AFE10C010FAFFFF0A10309FE5003093E5003093E5
1430AFE10D010FF3003E20300A0E100A81BE9A01DFE0A
1440AFE10E0100DC0A0E100D82DE904B04CE204D04DE2
1450AFE10F0100030A0E10D304BE50D305BE52332A0E1
1460AFE1100100E304BE50E305BE5090053E30300009A
1470AFE1110100E305BE5373083E20E304BE5020000EA
1480AFE1120100E305BE5303083E20E304BE50E305BE5
1490AFE1130100300A0E1C3FFFFEB0D305BE50F3003E2
1500AFE1140100E304BE50E305BE5090053E30300009A
1510AFE1150100E305BE5373083E20E304BE5020000EA
1520AFE1160100E305BE5303083E20E304BE50E305BE5
1530AFE1170100300A0E1B3FFFFEB00A81BE90DC0A0E1
1540AFE11801000D82DE904B04CE21CD04DE210000BE5
1550AFE11901014100BE518200BE588009FE5E50200EB
1560AFE11A01010301BE51C300BE514301BE520300BE5
1570AFE11B0100030A0E324300BE524201BE518301BE5
1580AFE11C010030052E10000003A120000EA1C004BE2
1590AFE11D010002090E520104BE2003091E500C093E5
1600AFE11E010043083E2003081E5003092E5042082E2
1610AFE11F010002080E50C0053E10200000A0030A0E3
1620AFE12001028300BE5050000EA24301BE5043083E2
1630AFE12101024300BE5E7FFFFEA0130A0E328300BE5
1640AFE12201028001BE500A81BE9E81EFE0A0DC0A0E1
1650AFE12301000D82DE904B04CE214D04DE210000BE5
1660AFE12401014100BE56C009FE5BA0200EB10301BE5
1670AFE12501018300BE50030A0E31C300BE51C201BE5
1680AFE12601014301BE5030052E10000003A0D0000EA
1690AFE12701018304BE2002093E5001092E5042082E2
1700AFE128010002083E5010071E30200000A0030A0E3
1710AFE12901020300BE5050000EA1C301BE5043083E2
1720AFE12A0101C300BE5ECFFFFEA0130A0E320300BE5
1730AFE12B01020001BE500A81BE9001FFE0A0DC0A0E1
1740AFE12C01000D82DE904B04CE224D04DE20130A0E3
1750AFE12D01024300BE5A4229FE58139A0E3023A83E2
1760AFE12E010003082E59820A0E390329FE5003093E5
1770AFE12F010033082E0003093E5023903E2000053E3
1780AFE1300100300001A74229FE58139A0E3033A83E2
1790AFE131010003082E568029FE5860200EBAF36A0E3
1800AFE1320100E3883E2003093E510300BE554029FE5
1810AFE133010800200EB10301BE5233CA0E1FF3003E2
1820AFE1340100300A0E165FFFFEB10301BE52338A0E1
1830AFE135010FF3003E20300A0E160FFFFEB10301BE5
1840AFE1360102334A0E1FF3003E20300A0E15BFFFFEB
1850AFE13701010305BE50300A0E158FFFFEB0A00A0E3
1860AFE13801030FFFFEB0D00A0E32EFFFFEBAF36A0E3
1870AFE1390100E3883E2043083E2003093E514300BE5
1880AFE13A010E4019FE5630200EB14301BE5233CA0E1
1890AFE13B010FF3003E20300A0E148FFFFEB14301BE5
1900AFE13C0102338A0E1FF3003E20300A0E143FFFFEB
1910AFE13D01014301BE52334A0E1FF3003E20300A0E1
1920AFE13E0103EFFFFEB14305BE50300A0E13BFFFFEB
1930AFE13F0100A00A0E313FFFFEB0D00A0E311FFFFEB
1940AFE140010AF36A0E30E3883E2083083E2003093E5
1950AFE14101018300BE574019FE5460200EB18301BE5
1960AFE142010233CA0E1FF3003E20300A0E12BFFFFEB
1970AFE14301018301BE52338A0E1FF3003E20300A0E1
1980AFE14401026FFFFEB18301BE52334A0E1FF3003E2
1990AFE1450100300A0E121FFFFEB18305BE50300A0E1
2000AFE1460101EFFFFEB0A00A0E3F6FEFFEB0D00A0E3
2010AFE147010F4FEFFEBE6FEFFEB0030A0E1FF3003E2
2020AFE148010000053E30000001A020000EA03FFFFEB
2030AFE1490102D004BE5F6FFFFEAF4009FE5250200EB
2040AFE14A010FEFEFFEB2D004BE5CD0000EBC00000EB
2050AFE14B010E0009FE51F0200EB18301BE528300BE5
2060AFE14C01014301BE52C300BE52C001BE5100100EB
2070AFE14D01028301BE5013643E228300BE52C301BE5
2080AFE14E010013683E22C300BE528301BE5000053E3
2090AFE14F010F4FFFFCAAE0000EB14001BE518101BE5
2100AFE15001049FFFFEB0030A0E1FF3003E2000053E3
2110AFE151010E6FFFF0A80009FE5060200EB10001BE5
2120AFE15201014101BE518201BE5D00000EB10001BE5
2130AFE15301014101BE518201BE50FFFFFEB0030A0E1
2140AFE154010FF3003E2000053E30200000A4C009FE5
2150AFE155010F80100EB010000EA44009FE5F50100EB
2160AFE156010930000EB3C009FE5F20100EB0000A0E3
2170AFE157010A4FEFFEB0030A0E30300A0E100A81BE9
2180AFE158010A01DFE0AA41DFE0AE01DFE0A0C1EFE0A
2190AFE159010381EFE0A641EFE0A181FFE0A281FFE0A
2200AFE15A0103C1FFE0A481FFE0AB41EFE0A0DC0A0E1
2210AFE15B01000D82DE904B04CE204D04DE210000BE5
2220AFE15C01010301BE5013043E210300BE5010073E3
2230AFE15D010FAFFFF1A00A81BE90DC0A0E100D82DE9
2240AFE15E01004B04CE208D04DE210000BE510301BE5
2250AFE15F01014300BE514301BE50300A0E100A81BE9
2260AFE1600100DC0A0E100D82DE904B04CE204D04DE2
2270AFE1610102228A0E3012A82E2042082E2E134A0E3
2280AFE162010023883E2033C83E2003082E50333A0E3
2290AFE163010053983E2003093E510300BE500A81BE9
2300AFE1640100DC0A0E100D82DE904B04CE204D04DE2
2310AFE1650102228A0E3012A82E2042082E29134A0E3
2320AFE166010023883E2033C83E2003082E5C136A0E3
2330AFE167010003093E510300BE52228A0E3012A82E2
2340AFE168010042082E2E134A0E3023883E2033C83E2
2350AFE169010003082E50333A0E3073983E20020A0E3
2360AFE16A010002083E52228A0E3012A82E2042082E2
2370AFE16B0108134A0E3023883E2033C83E2003082E5
2380AFE16C0100333A0E3003093E510300BE5CBFFFFEB
2390AFE16D01010301BE50300A0E100A81BE90DC0A0E1
2400AFE16E01000D82DE904B04CE208D04DE2D3FFFFEB
2410AFE16F0100030A0E110300BE510301BE5023503E2
2420AFE170010000053E30500000A10301BE5073703E2
2430AFE171010000053E30100000A10001BE5ADFFFFEB
2440AFE17201010301BE5803003E2000053E30500000A
2450AFE17301010301BE51C3003E2000053E30100000A
2460AFE17401010001BE5A3FFFFEB10201BE50235A0E3
2470AFE175010803083E2030052E10200001A0130A0E3
2480AFE17601014300BE5010000EA0030A0E314300BE5
2490AFE17701014001BE500A81BE90DC0A0E100D82DE9
2500AFE17801004B04CE204D04DE22228A0E3012A82E2
2510AFE179010042082E29134A0E3023883E2033C83E2
2520AFE17A010003082E5C136A0E3003093E510300BE5
2530AFE17B01000A81BE90DC0A0E100D82DE904B04CE2
2540AFE17C010ECFFFFEB2228A0E3012A82E2042082E2
2550AFE17D0108134A0E3023883E2033C83E2003082E5
2560AFE17E01000A81BE90DC0A0E100D82DE904B04CE2
2570AFE17F01004D04DE22228A0E3012A82E2042082E2
2580AFE1800102238A0E3013A83E2043083E2003093E5
2590AFE181010023183E3003082E52228A0E3012A82E2
2600AFE1820102238A0E3013A83E2003093E5023183E3
2610AFE183010003082E5FA0FA0E35BFFFFEB2228A0E3
2620AFE184010012A82E2042082E2B134A0E3023883E2
2630AFE185010033C83E2003082E50333A0E3233983E2
2640AFE186010033B83E2003093E510300BE500A81BE9
2650AFE1870100DC0A0E100D82DE904B04CE21CD04DE2
2660AFE18801010000BE514100BE518200BE50030A0E3
2670AFE1890101C300BE51C201BE518301BE5030052E1
2680AFE18A0100000003A190000EAB2FFFFEB2228A0E3
2690AFE18B010012A82E2042082E2F134A0E3023883E2
2700AFE18C010033C83E2003082E514201BE51C301BE5
2710AFE18D010031082E010201BE51C301BE5033082E0
2720AFE18E010003093E5003081E57BFFFFEB0030A0E1
2730AFE18F010FF3003E2000053E3FAFFFF0AACFFFFEB
2740AFE1900101C301BE5043083E21C300BE5E0FFFFEA
2750AFE19101000A81BE90DC0A0E100D82DE904B04CE2
2760AFE1920100CD04DE210000BE52228A0E3012A82E2
2770AFE193010042082E28134A0E3023883E2033C83E2
2780AFE194010003082E510301BE5003093E514300BE5
2790AFE1950102228A0E3012A82E2042082E29134A0E3
2800AFE196010023883E2033C83E2003082E510301BE5
2810AFE197010003093E518300BE52228A0E3012A82E2
2820AFE198010042082E2E134A0E3023883E2033C83E2
2830AFE199010003082E50229A0E310301BE5032082E0
2840AFE19A0100030A0E3003082E52228A0E3012A82E2
2850AFE19B010042082E28134A0E3023883E2033C83E2
2860AFE19C010003082E510201BE50D3AA0E3D03083E2
2870AFE19D010033883E1003082E53FFFFFEB0030A0E1
2880AFE19E010FF3003E2000053E3FAFFFF0A70FFFFEB
2890AFE19F01000A81BE90DC0A0E100D82DE904B04CE2
2900AFE1A00105CFFFFEB2228A0E3012A82E2042082E2
2910AFE1A1010E134A0E3023883E2033C83E2003082E5
2920AFE1A20100333A0E3033983E20020A0E3002083E5
2930AFE1A30102228A0E3012A82E2042082E28134A0E3
2940AFE1A4010023883E2033C83E2003082E50323A0E3
2950AFE1A5010032982E20339A0E3C03083E2033883E1
2960AFE1A6010003082E500A81BE90DC0A0E100D82DE9
2970AFE1A701004B04CE23FFFFFEB2228A0E3012A82E2
2980AFE1A8010042082E2E134A0E3023883E2033C83E2
2990AFE1A9010003082E50333A0E30A3983E20020A0E3
3000AFE1AA010002083E52228A0E3012A82E2042082E2
3010AFE1AB0108134A0E3023883E2033C83E2003082E5
3020AFE1AC0100323A0E30A2982E20339A0E3C03083E2
3030AFE1AD010033883E1003082E500A81BE90DC0A0E1
3040AFE1AE01000D82DE904B04CE28729A0E3222E82E2
3050AFE1AF0108739A0E3223E83E2003093E51E3CC3E3
3060AFE1B0010003082E58729A0E38E2F82E28739A0E3
3070AFE1B10108E3F83E2003093E51E3CC3E3003082E5
3080AFE1B20108139A0E3823D83E20520A0E3002083E5
3090AFE1B30108129A0E3822D82E2042082E20139A0E3
3100AFE1B4010273083E2003082E58139A0E3823D83E2
3110AFE1B50100C3083E20120A0E3002083E58129A0E3
3120AFE1B6010822D82E2102082E22A3DA0E3013083E2
3130AFE1B7010003082E58139A0E3823D83E2243083E2
3140AFE1B80100F20A0E3002083E58139A0E3823D83E2
3150AFE1B9010283083E28A20A0E3002083E58139A0E3
3160AFE1BA010823D83E22C3083E20820A0E3002083E5
3170AFE1BB01000A81BE90DC0A0E100D82DE904B04CE2
3180AFE1BC0108139A0E3823D83E2183083E2003093E5
3190AFE1BD010013003E2FF3003E20300A0E100A81BE9
3200AFE1BE0100DC0A0E100D82DE904B04CE204D04DE2
3210AFE1BF0100030A0E10D304BE58139A0E3823D83E2
3220AFE1C0010183083E2003093E5013903E2000053E3
3230AFE1C1010F8FFFF0A8139A0E3813D83E20D205BE5
3240AFE1C2010002083E50D305BE50A0053E30A00001A
3250AFE1C30108139A0E3823D83E2183083E2003093E5
3260AFE1C4010013903E2000053E3F8FFFF0A8139A0E3
3270AFE1C5010813D83E20D20A0E3002083E500A81BE9
3280AFE1C60100DC0A0E100D82DE904B04CE20000A0E1
3290AFE1C7010CFFFFFEB0030A0E1FF3003E2000053E3
3300AFE1C8010FAFFFF0A8139A0E3023A83E2003093E5
3310AFE1C9010FF3003E20300A0E100A81BE90DC0A0E1
3320AFE1CA01000D82DE904B04CE204D04DE20030A0E1
3330AFE1CB0100D304BE50D305BE52332A0E10E304BE5
3340AFE1CC0100E305BE5090053E30300009A0E305BE5
3350AFE1CD010373083E20E304BE5020000EA0E305BE5
3360AFE1CE010303083E20E304BE50E305BE50300A0E1
3370AFE1CF010BAFFFFEB0D305BE50F3003E20E304BE5
3380AFE1D00100E305BE5090053E30300009A0E305BE5
3390AFE1D1010373083E20E304BE5020000EA0E305BE5
3400AFE1D2010303083E20E304BE50E305BE50300A0E1
3410AFE1D3010AAFFFFEB00A81BE90DC0A0E100D82DE9
3420AFE1D401004B04CE204D04DE210000BE510301BE5
3430AFE1D50100030D3E5000053E30000001A080000EA
3440AFE1D601010104BE2003091E50320A0E10020D2E5
3450AFE1D7010013083E2003081E50200A0E197FFFFEB
3460AFE1D8008F1FFFFEA00A81BE9
3470AFE1DA4100A0D4D58314144532053796E632D666C
3480AFE1DB4106173682050726F6772616D6D696E6720
3490AFE1DC4105574696C6974792076302E3520323030
3500AFE1DD410322F30382F32310A0D000000536F7572
3510AFE1DE41063652061646472657373202873746F72
3520AFE1DF410656420696E2030783041464530303030
3530AFE1E0410293A2030780000005461726765742061
3540AFE1E1410646472657373202873746F7265642069
3550AFE1E24106E2030783041464530303034293A2030
3560AFE1E34107800000053697A652020202020202020
3570AFE1E44102020202873746F72656420696E203078
3580AFE1E54103041464530303038293A203078000000
3590AFE1E6410507265737320616E79206B657920746F
3600AFE1E74102073746172742070726F6772616D6D69
3610AFE1E84106E67202E2E2E00000A0D45726173696E
3620AFE1E94106720666C617368202E2E2E000A0D5072
3630AFE1EA4106F6772616D6D696E67202E2E2E000000
3640AFE1EB4100A0D50726F6772616D6D696E67206669
3650AFE1EC4106E69736865642E0A0D50726573732027
3660AFE1ED410612720746F20636F6E74696E7565202E
3670AFE1EE4102E2E2E000A0D566572696679696E6720
3680AFE1EF410666C617368202E2E2E0000000A0D426C
3690AFE1F0410616E6B20636865636B696E67202E2E2E
3700AFE1F1410000000000A45726173696E67202E2E2E
3710AFE1F2410000000000A50726F6772616D6D696E67
3720AFE1F3410202E2E2E000000002073756363656564
3730AFE1F44102E0A0000206661696C656420210A0000
3740AFE100000
375 "
376}
377
378#########################################################
379
380if [ "$#" -eq 2 ] ; then
381 output_init > $2
382 output_uboot >> $2
383 output_flashprog >> $2
384else
385 output_init;
386 output_uboot;
387 output_flashprog;
388fi