From b7f9ffb6c0f4a1e1c9c25a391a1b1d90bca4cdfc Mon Sep 17 00:00:00 2001 From: Jim Paris Date: Tue, 18 Feb 2020 16:36:04 -0500 Subject: [PATCH] cc2538 flash: fix up flash address base confusion Change-Id: Ifccf4e861e913e5711ca6c2ac61fa828c4a56d87 --- contrib/loaders/flash/cc2538/cc2538_algo.inc | 200 +++++++++---------- contrib/loaders/flash/cc2538/flash.c | 10 +- contrib/loaders/flash/cc2538/flash.h | 6 +- contrib/loaders/flash/cc2538/flashloader.c | 15 +- contrib/loaders/flash/cc2538/flashloader.h | 2 +- src/flash/nor/cc2538.c | 2 +- 6 files changed, 122 insertions(+), 113 deletions(-) diff --git a/contrib/loaders/flash/cc2538/cc2538_algo.inc b/contrib/loaders/flash/cc2538/cc2538_algo.inc index 38617cd22..1553fafa9 100644 --- a/contrib/loaders/flash/cc2538/cc2538_algo.inc +++ b/contrib/loaders/flash/cc2538/cc2538_algo.inc @@ -1,19 +1,19 @@ /* Autogenerated with ../../../../src/helper/bin2char.sh */ 0x72,0xb6,0x4f,0xf0,0x00,0x00,0x80,0xf3,0x14,0x88,0xbf,0xf3,0x6f,0x8f,0x09,0x48, 0x85,0x46,0xbf,0xf3,0x6f,0x8f,0x4f,0xf0,0x00,0x00,0x07,0x49,0x07,0x4a,0x91,0x42, -0xb8,0xbf,0x41,0xf8,0x04,0x0b,0xfa,0xdb,0x00,0xf0,0x08,0xfa,0x00,0xf0,0x2c,0xf9, -0xfe,0xe7,0x00,0x00,0xd8,0x1b,0x00,0x20,0x1c,0x0b,0x00,0x20,0x40,0x0c,0x00,0x20, +0xb8,0xbf,0x41,0xf8,0x04,0x0b,0xfa,0xdb,0x00,0xf0,0x1a,0xfa,0x00,0xf0,0x3e,0xf9, +0xfe,0xe7,0x00,0x00,0xd8,0x1b,0x00,0x20,0x44,0x0b,0x00,0x20,0x68,0x0c,0x00,0x20, 0x06,0x48,0x07,0x4b,0x10,0xb5,0x83,0x42,0x04,0xd0,0x06,0x4b,0x00,0x2b,0x01,0xd0, -0x00,0xf0,0x4e,0xf8,0x10,0xbc,0x01,0xbc,0x00,0x47,0xc0,0x46,0x18,0x0b,0x00,0x20, -0x18,0x0b,0x00,0x20,0x00,0x00,0x00,0x00,0x08,0x48,0x09,0x49,0x09,0x1a,0x89,0x10, +0x00,0xf0,0x4e,0xf8,0x10,0xbc,0x01,0xbc,0x00,0x47,0xc0,0x46,0x40,0x0b,0x00,0x20, +0x40,0x0b,0x00,0x20,0x00,0x00,0x00,0x00,0x08,0x48,0x09,0x49,0x09,0x1a,0x89,0x10, 0xcb,0x0f,0x59,0x18,0x10,0xb5,0x49,0x10,0x04,0xd0,0x06,0x4b,0x00,0x2b,0x01,0xd0, -0x00,0xf0,0x36,0xf8,0x10,0xbc,0x01,0xbc,0x00,0x47,0xc0,0x46,0x18,0x0b,0x00,0x20, -0x18,0x0b,0x00,0x20,0x00,0x00,0x00,0x00,0x10,0xb5,0x08,0x4c,0x23,0x78,0x00,0x2b, +0x00,0xf0,0x36,0xf8,0x10,0xbc,0x01,0xbc,0x00,0x47,0xc0,0x46,0x40,0x0b,0x00,0x20, +0x40,0x0b,0x00,0x20,0x00,0x00,0x00,0x00,0x10,0xb5,0x08,0x4c,0x23,0x78,0x00,0x2b, 0x09,0xd1,0xff,0xf7,0xcd,0xff,0x06,0x4b,0x00,0x2b,0x02,0xd0,0x05,0x48,0xaf,0xf3, -0x00,0x80,0x01,0x23,0x23,0x70,0x10,0xbc,0x01,0xbc,0x00,0x47,0x1c,0x0b,0x00,0x20, -0x00,0x00,0x00,0x00,0xc4,0x06,0x00,0x20,0x06,0x4b,0x10,0xb5,0x00,0x2b,0x03,0xd0, +0x00,0x80,0x01,0x23,0x23,0x70,0x10,0xbc,0x01,0xbc,0x00,0x47,0x44,0x0b,0x00,0x20, +0x00,0x00,0x00,0x00,0xe8,0x06,0x00,0x20,0x06,0x4b,0x10,0xb5,0x00,0x2b,0x03,0xd0, 0x05,0x49,0x06,0x48,0xaf,0xf3,0x00,0x80,0xff,0xf7,0xc6,0xff,0x10,0xbc,0x01,0xbc, -0x00,0x47,0xc0,0x46,0x00,0x00,0x00,0x00,0x20,0x0b,0x00,0x20,0xc4,0x06,0x00,0x20, +0x00,0x47,0xc0,0x46,0x00,0x00,0x00,0x00,0x48,0x0b,0x00,0x20,0xe8,0x06,0x00,0x20, 0x18,0x47,0xc0,0x46,0xd4,0x30,0x9f,0xe5,0x00,0x00,0x53,0xe3,0xc8,0x30,0x9f,0x05, 0x03,0xd0,0xa0,0xe1,0x00,0x20,0x0f,0xe1,0x0f,0x00,0x12,0xe3,0x15,0x00,0x00,0x0a, 0xd1,0xf0,0x21,0xe3,0x03,0xd0,0xa0,0xe1,0x01,0xaa,0x4d,0xe2,0x0a,0x30,0xa0,0xe1, @@ -23,95 +23,96 @@ 0xff,0x30,0xc3,0xe3,0xff,0x3c,0xc3,0xe3,0x04,0x30,0x03,0xe5,0x00,0x20,0x53,0xe9, 0xc0,0x20,0x82,0xe3,0x02,0xf0,0x21,0xe1,0x01,0xa8,0x43,0xe2,0x00,0x10,0xb0,0xe3, 0x01,0xb0,0xa0,0xe1,0x01,0x70,0xa0,0xe1,0x5c,0x00,0x9f,0xe5,0x5c,0x20,0x9f,0xe5, -0x00,0x20,0x52,0xe0,0x01,0x30,0x8f,0xe2,0x13,0xff,0x2f,0xe1,0x00,0xf0,0x80,0xf9, +0x00,0x20,0x52,0xe0,0x01,0x30,0x8f,0xe2,0x13,0xff,0x2f,0xe1,0x00,0xf0,0x92,0xf9, 0x10,0x4b,0x00,0x2b,0x01,0xd0,0xfe,0x46,0x9f,0x46,0x0f,0x4b,0x00,0x2b,0x01,0xd0, 0xfe,0x46,0x9f,0x46,0x00,0x20,0x00,0x21,0x04,0x00,0x0d,0x00,0x0d,0x48,0x00,0xf0, -0x09,0xf9,0x00,0xf0,0x43,0xf9,0x20,0x00,0x29,0x00,0x00,0xf0,0x65,0xf8,0x00,0xf0, -0x0b,0xf9,0x7b,0x46,0x18,0x47,0x00,0x00,0x11,0x00,0x00,0xef,0x00,0x00,0x08,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x0b,0x00,0x20, -0x40,0x0c,0x00,0x20,0x01,0x04,0x00,0x20,0x38,0xb5,0x0d,0x46,0x14,0x46,0x00,0x21, -0x28,0x22,0x00,0xf0,0x4d,0xf9,0x4f,0xf4,0x80,0x72,0x05,0x61,0x44,0x62,0x00,0x21, -0x02,0x48,0x00,0xf0,0x45,0xf9,0x00,0x20,0x38,0xbd,0x00,0xbf,0x38,0x0b,0x00,0x20, -0x10,0xb5,0x00,0xf0,0xa7,0xf8,0x04,0x46,0x38,0xb9,0x4f,0xf4,0x80,0x72,0x01,0x21, -0x03,0x48,0x00,0xf0,0x35,0xf9,0x20,0x46,0x10,0xbd,0x40,0xf2,0x01,0x14,0xfa,0xe7, -0x38,0x0b,0x00,0x20,0xf8,0xb5,0x01,0x27,0xa1,0xf5,0x00,0x11,0x01,0x39,0xa0,0xf5, -0x00,0x14,0x01,0x44,0x0c,0x4e,0xe4,0x0a,0xcd,0x0a,0xac,0x42,0x01,0xd9,0x00,0x20, -0x0e,0xe0,0xa3,0x5d,0x73,0xb9,0x04,0xf5,0x80,0x60,0xc0,0x02,0x00,0xf0,0x60,0xf8, -0x38,0xb1,0x00,0x04,0x00,0xf4,0x7f,0x00,0x40,0xea,0x04,0x60,0x40,0xf4,0x81,0x70, -0xf8,0xbd,0xa7,0x55,0x01,0x34,0xe8,0xe7,0x38,0x0b,0x00,0x20,0x08,0xb5,0x00,0xf0, -0x89,0xf8,0x00,0x20,0x08,0xbd,0x00,0x00,0xf8,0xb5,0x20,0x4a,0x20,0x49,0x21,0x48, -0x20,0x4e,0xff,0xf7,0xa9,0xff,0x00,0x23,0x14,0x25,0x34,0x46,0x1e,0x4f,0x3b,0x60, -0x3b,0x68,0x05,0xfb,0x03,0x63,0x03,0xf1,0x08,0x02,0x51,0x68,0x00,0x29,0xfc,0xd0, -0x12,0x68,0x02,0x2a,0x0d,0xd0,0x03,0x2a,0x11,0xd0,0x01,0x2a,0x14,0xd1,0xff,0xf7, -0xa7,0xff,0x3a,0x68,0x98,0xb1,0x14,0x22,0x3b,0x68,0x02,0xfb,0x03,0x44,0xe0,0x60, -0xfe,0xe7,0x18,0x69,0x19,0x68,0x5a,0x68,0xff,0xf7,0xd0,0xff,0xf1,0xe7,0x18,0x68, -0x59,0x68,0xff,0xf7,0xa7,0xff,0xec,0xe7,0x40,0xf2,0x05,0x10,0xeb,0xe7,0x05,0xfb, -0x02,0x43,0x19,0x7b,0x18,0x73,0x59,0x7b,0x58,0x73,0x99,0x7b,0x82,0xf0,0x01,0x02, -0x98,0x73,0xd9,0x7b,0x3a,0x60,0xd8,0x73,0xca,0xe7,0x00,0xbf,0x00,0x24,0x00,0x20, -0x00,0x1c,0x00,0x20,0xd8,0x1b,0x00,0x20,0x38,0x0c,0x00,0x20,0xfe,0xe7,0x00,0x00, -0x08,0xb5,0x00,0x23,0x1a,0x58,0x01,0x32,0x0f,0xd1,0x04,0x33,0xb3,0xf5,0x00,0x6f, -0xf8,0xd1,0x00,0x20,0x08,0xbd,0x82,0x1c,0x04,0xd0,0x00,0x28,0xf9,0xd0,0x40,0xf2, -0x03,0x10,0xf7,0xe7,0x4f,0xf4,0x81,0x70,0xf4,0xe7,0x05,0x4b,0x4f,0xf4,0x00,0x61, -0x1b,0x68,0xdb,0x68,0x98,0x47,0x43,0x1c,0xed,0xd1,0x40,0xf2,0x01,0x10,0xe9,0xe7, -0xd8,0x06,0x00,0x20,0x70,0xb5,0x0a,0x4b,0x00,0x24,0x1b,0x68,0x5b,0x68,0x98,0x47, -0xc5,0x0a,0x05,0xf2,0xff,0x36,0xa5,0x42,0x01,0xd1,0x00,0x20,0x06,0xe0,0x30,0x1b, -0xc0,0x02,0xff,0xf7,0xcd,0xff,0x01,0x34,0x00,0x28,0xf4,0xd0,0x70,0xbd,0x00,0xbf, -0xd8,0x06,0x00,0x20,0x08,0xb5,0x0a,0x4b,0x1b,0x68,0x1b,0x69,0x98,0x47,0x42,0x1c, -0x07,0xd0,0x83,0x1c,0x08,0xd0,0x00,0x28,0x14,0xbf,0x4f,0xf4,0x83,0x70,0x00,0x20, -0x08,0xbd,0x4f,0xf4,0x82,0x70,0xfb,0xe7,0x40,0xf2,0x05,0x10,0xf8,0xe7,0x00,0xbf, -0xd8,0x06,0x00,0x20,0x10,0xb5,0x01,0x00,0x00,0x23,0x00,0x22,0x00,0x20,0x00,0xf0, -0xb1,0xf8,0x10,0xbc,0x02,0xbc,0x08,0x47,0x10,0xb5,0x00,0x21,0x04,0x00,0x00,0xf0, -0xef,0xf8,0x05,0x4b,0x18,0x68,0xc3,0x6b,0x00,0x2b,0x01,0xd0,0x00,0xf0,0x06,0xf8, -0x20,0x00,0xff,0xf7,0x93,0xff,0xc0,0x46,0xd0,0x06,0x00,0x20,0x18,0x47,0xc0,0x46, -0x70,0xb5,0x0a,0x4b,0x0a,0x4c,0xe4,0x1a,0xa4,0x10,0x0a,0xd0,0x09,0x4a,0xa5,0x18, -0xad,0x00,0xed,0x18,0x2b,0x68,0x01,0x3c,0x00,0xf0,0x0e,0xf8,0x04,0x3d,0x00,0x2c, -0xf8,0xd1,0x00,0xf0,0x49,0xf9,0x70,0xbc,0x01,0xbc,0x00,0x47,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x3f,0x18,0x47,0xc0,0x46,0x70,0xb5,0x0f,0x4e, -0x0f,0x4d,0xad,0x1b,0xad,0x10,0x07,0xd0,0x00,0x24,0xa3,0x00,0xf3,0x58,0x01,0x34, -0x00,0xf0,0x1c,0xf8,0xa5,0x42,0xf8,0xd1,0x00,0xf0,0x28,0xf9,0x09,0x4e,0x0a,0x4d, -0xad,0x1b,0xad,0x10,0x07,0xd0,0x00,0x24,0xa3,0x00,0xf3,0x58,0x01,0x34,0x00,0xf0, -0x0d,0xf8,0xa5,0x42,0xf8,0xd1,0x70,0xbc,0x01,0xbc,0x00,0x47,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x47,0xc0,0x46, -0xf0,0xb5,0x83,0x07,0x4a,0xd0,0x54,0x1e,0x00,0x2a,0x44,0xd0,0x0d,0x06,0x2d,0x0e, -0x02,0x00,0x03,0x26,0x02,0xe0,0x1a,0x00,0x01,0x3c,0x3c,0xd3,0x53,0x1c,0x15,0x70, -0x33,0x42,0xf8,0xd1,0x03,0x2c,0x2d,0xd9,0xff,0x22,0x0a,0x40,0x15,0x02,0x15,0x43, -0x2a,0x04,0x15,0x43,0x0f,0x2c,0x16,0xd9,0x27,0x00,0x10,0x3f,0x3f,0x09,0x3e,0x01, -0xb4,0x46,0x1e,0x00,0x1a,0x00,0x10,0x36,0x66,0x44,0x15,0x60,0x55,0x60,0x95,0x60, -0xd5,0x60,0x10,0x32,0xb2,0x42,0xf8,0xd1,0x0f,0x22,0x01,0x37,0x3f,0x01,0xdb,0x19, -0x14,0x40,0x03,0x2c,0x0e,0xd9,0x26,0x1f,0xb6,0x08,0xb7,0x00,0xbc,0x46,0x1a,0x00, -0x1f,0x1d,0x67,0x44,0x20,0xc2,0xba,0x42,0xfc,0xd1,0x03,0x22,0x01,0x36,0xb6,0x00, -0x9b,0x19,0x14,0x40,0x00,0x2c,0x06,0xd0,0x09,0x06,0x1c,0x19,0x09,0x0e,0x19,0x70, -0x01,0x33,0x9c,0x42,0xfb,0xd1,0xf0,0xbc,0x02,0xbc,0x08,0x47,0x14,0x00,0x03,0x00, -0xc0,0xe7,0xc0,0x46,0xf0,0xb5,0xc6,0x46,0x00,0xb5,0x20,0x4c,0x24,0x68,0x82,0xb0, -0x01,0x94,0xa4,0x24,0x01,0x9d,0x64,0x00,0x2d,0x59,0x00,0x2d,0x2d,0xd0,0x6c,0x68, -0x1f,0x2c,0x30,0xdc,0x00,0x28,0x0b,0xd1,0x00,0x20,0x63,0x1c,0x02,0x34,0xa4,0x00, -0x6b,0x60,0x61,0x51,0x02,0xb0,0x04,0xbc,0x90,0x46,0xf0,0xbc,0x02,0xbc,0x08,0x47, -0x88,0x27,0xa6,0x00,0xae,0x19,0xf2,0x51,0x01,0x37,0xff,0x37,0xbc,0x46,0x01,0x22, -0xac,0x44,0x67,0x46,0xa2,0x40,0x3f,0x68,0x90,0x46,0x17,0x43,0x62,0x46,0x17,0x60, -0x84,0x27,0x7f,0x00,0xf3,0x51,0x02,0x28,0xde,0xd1,0x2b,0x00,0x40,0x46,0x8d,0x33, -0xff,0x33,0x1a,0x68,0x10,0x43,0x18,0x60,0xd6,0xe7,0x01,0x9d,0x01,0x9e,0x4d,0x35, -0xff,0x35,0x35,0x51,0xcb,0xe7,0x01,0x20,0x40,0x42,0xd3,0xe7,0xd0,0x06,0x00,0x20, -0xf0,0xb5,0x4e,0x46,0xde,0x46,0x57,0x46,0x45,0x46,0xe0,0xb5,0x2e,0x4b,0x1b,0x68, -0x83,0xb0,0x1a,0x00,0x00,0x93,0xa4,0x23,0x5b,0x00,0xd6,0x58,0x01,0x22,0x01,0x90, -0x0f,0x00,0x93,0x46,0x99,0x46,0x00,0x2e,0x31,0xd0,0x74,0x68,0x65,0x1e,0x2e,0xd4, -0xc4,0x23,0x5b,0x00,0x9a,0x46,0x01,0x34,0xa4,0x00,0x34,0x19,0xb2,0x44,0x02,0xe0, -0x04,0x3c,0x01,0x3d,0x23,0xd3,0x00,0x2f,0x04,0xd0,0x63,0x1c,0xff,0x33,0x1b,0x68, -0xbb,0x42,0xf5,0xd1,0x73,0x68,0x01,0x3b,0x22,0x68,0xab,0x42,0x20,0xd0,0x00,0x23, -0x23,0x60,0x00,0x2a,0xec,0xd0,0x73,0x68,0x98,0x46,0x5b,0x46,0x51,0x46,0xab,0x40, -0x09,0x68,0x19,0x42,0x16,0xd1,0x00,0xf0,0x29,0xf8,0x4a,0x46,0x00,0x9b,0x9b,0x58, -0x72,0x68,0x42,0x45,0x01,0xd1,0x9e,0x42,0xda,0xd0,0x1e,0x1e,0xcd,0xd1,0x03,0xb0, -0x3c,0xbc,0x90,0x46,0x99,0x46,0xa2,0x46,0xab,0x46,0xf0,0xbc,0x01,0xbc,0x00,0x47, -0x75,0x60,0xde,0xe7,0x30,0x00,0x21,0x00,0x8d,0x30,0xff,0x30,0x00,0x68,0x80,0x31, -0x09,0x68,0x18,0x42,0x03,0xd1,0x01,0x98,0x00,0xf0,0x08,0xf8,0xdd,0xe7,0x08,0x00, -0x00,0xf0,0x04,0xf8,0xd9,0xe7,0xc0,0x46,0xd0,0x06,0x00,0x20,0x10,0x47,0xc0,0x46, -0x04,0x4b,0x10,0xb5,0x00,0x2b,0x02,0xd0,0x03,0x48,0xff,0xf7,0x93,0xfe,0x10,0xbc, -0x01,0xbc,0x00,0x47,0x00,0x00,0x00,0x00,0x01,0x04,0x00,0x20,0xf8,0xb5,0xc0,0x46, -0xf8,0xbc,0x08,0xbc,0x9e,0x46,0x70,0x47,0xf8,0xb5,0xc0,0x46,0xf8,0xbc,0x08,0xbc, -0x9e,0x46,0x70,0x47,0x00,0x00,0x00,0x00,0x2c,0xfa,0xff,0x7f,0x01,0x00,0x00,0x00, -0xe8,0x06,0x00,0x20,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xe8,0x06,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd4,0x09,0x00,0x20, -0x3c,0x0a,0x00,0x20,0xa4,0x0a,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0xf9,0x00,0xf0,0x55,0xf9,0x20,0x00,0x29,0x00,0x00,0xf0,0x77,0xf8,0x00,0xf0, +0x1d,0xf9,0x7b,0x46,0x18,0x47,0x00,0x00,0x11,0x00,0x00,0xef,0x00,0x00,0x08,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x0b,0x00,0x20, +0x68,0x0c,0x00,0x20,0x25,0x04,0x00,0x20,0x38,0xb5,0x0d,0x46,0x14,0x46,0x00,0x21, +0x28,0x22,0x00,0xf0,0x5f,0xf9,0x4f,0xf4,0x80,0x72,0x05,0x61,0x44,0x62,0x00,0x21, +0x02,0x48,0x00,0xf0,0x57,0xf9,0x00,0x20,0x38,0xbd,0x00,0xbf,0x60,0x0b,0x00,0x20, +0x10,0xb5,0x00,0xf0,0xbd,0xf8,0x04,0x46,0x38,0xb9,0x4f,0xf4,0x80,0x72,0x01,0x21, +0x03,0x48,0x00,0xf0,0x47,0xf9,0x20,0x46,0x10,0xbd,0x40,0xf2,0x01,0x14,0xfa,0xe7, +0x60,0x0b,0x00,0x20,0xb0,0xf5,0x00,0x1f,0xf8,0xb5,0x21,0xd3,0x01,0x44,0xb1,0xf5, +0x20,0x1f,0x1d,0xd8,0x01,0x27,0xa1,0xf5,0x00,0x11,0xa0,0xf5,0x00,0x10,0x01,0x39, +0x0d,0x4e,0xc4,0x0a,0xcd,0x0a,0xac,0x42,0x01,0xd9,0x00,0x20,0x0c,0xe0,0xa3,0x5d, +0x63,0xb9,0x20,0x46,0x00,0xf0,0x6e,0xf8,0x38,0xb1,0x00,0x04,0x00,0xf4,0x7f,0x00, +0x40,0xea,0x04,0x60,0x40,0xf4,0x81,0x70,0xf8,0xbd,0xa7,0x55,0x01,0x34,0xea,0xe7, +0x4f,0xf4,0x82,0x70,0xf8,0xe7,0x00,0xbf,0x60,0x0b,0x00,0x20,0xb1,0xf5,0x00,0x1f, +0x10,0xb5,0x0b,0x46,0x07,0xd3,0x13,0x44,0xb3,0xf5,0x20,0x1f,0x03,0xd8,0x00,0xf0, +0x8b,0xf8,0x00,0x20,0x10,0xbd,0x4f,0xf4,0x82,0x70,0xfb,0xe7,0xf8,0xb5,0x20,0x4a, +0x20,0x49,0x21,0x48,0x20,0x4e,0xff,0xf7,0x97,0xff,0x00,0x23,0x14,0x25,0x34,0x46, +0x1e,0x4f,0x3b,0x60,0x3b,0x68,0x05,0xfb,0x03,0x63,0x03,0xf1,0x08,0x02,0x51,0x68, +0x00,0x29,0xfc,0xd0,0x12,0x68,0x02,0x2a,0x0d,0xd0,0x03,0x2a,0x11,0xd0,0x01,0x2a, +0x14,0xd1,0xff,0xf7,0x95,0xff,0x3a,0x68,0x98,0xb1,0x14,0x22,0x3b,0x68,0x02,0xfb, +0x03,0x44,0xe0,0x60,0xfe,0xe7,0x18,0x69,0x19,0x68,0x5a,0x68,0xff,0xf7,0xc6,0xff, +0xf1,0xe7,0x18,0x68,0x59,0x68,0xff,0xf7,0x95,0xff,0xec,0xe7,0x40,0xf2,0x05,0x10, +0xeb,0xe7,0x05,0xfb,0x02,0x43,0x19,0x7b,0x18,0x73,0x59,0x7b,0x58,0x73,0x99,0x7b, +0x82,0xf0,0x01,0x02,0x98,0x73,0xd9,0x7b,0x3a,0x60,0xd8,0x73,0xca,0xe7,0x00,0xbf, +0x00,0x24,0x00,0x20,0x00,0x1c,0x00,0x20,0xd8,0x1b,0x00,0x20,0x60,0x0c,0x00,0x20, +0xfe,0xe7,0x00,0x00,0x08,0xb5,0x00,0x23,0x00,0xf5,0x80,0x60,0xc0,0x02,0x1a,0x58, +0x01,0x32,0x0f,0xd1,0x04,0x33,0xb3,0xf5,0x00,0x6f,0xf8,0xd1,0x00,0x20,0x08,0xbd, +0x82,0x1c,0x04,0xd0,0x00,0x28,0xf9,0xd0,0x40,0xf2,0x03,0x10,0xf7,0xe7,0x4f,0xf4, +0x81,0x70,0xf4,0xe7,0x05,0x4b,0x4f,0xf4,0x00,0x61,0x1b,0x68,0xdb,0x68,0x98,0x47, +0x43,0x1c,0xed,0xd1,0x40,0xf2,0x01,0x10,0xe9,0xe7,0x00,0xbf,0x00,0x07,0x00,0x20, +0x10,0xb5,0x08,0x4b,0x1b,0x68,0x5b,0x68,0x98,0x47,0xc0,0x0a,0x44,0x1e,0x63,0x1c, +0x01,0xd1,0x00,0x20,0x10,0xbd,0x20,0x46,0xff,0xf7,0xcc,0xff,0x00,0x28,0xf9,0xd1, +0x01,0x3c,0xf4,0xe7,0x00,0x07,0x00,0x20,0x08,0xb5,0x0a,0x4b,0x1b,0x68,0x1b,0x69, +0x98,0x47,0x42,0x1c,0x07,0xd0,0x83,0x1c,0x08,0xd0,0x00,0x28,0x14,0xbf,0x4f,0xf4, +0x83,0x70,0x00,0x20,0x08,0xbd,0x4f,0xf4,0x82,0x70,0xfb,0xe7,0x40,0xf2,0x05,0x10, +0xf8,0xe7,0x00,0xbf,0x00,0x07,0x00,0x20,0x10,0xb5,0x01,0x00,0x00,0x23,0x00,0x22, +0x00,0x20,0x00,0xf0,0xb1,0xf8,0x10,0xbc,0x02,0xbc,0x08,0x47,0x10,0xb5,0x00,0x21, +0x04,0x00,0x00,0xf0,0xef,0xf8,0x05,0x4b,0x18,0x68,0xc3,0x6b,0x00,0x2b,0x01,0xd0, +0x00,0xf0,0x06,0xf8,0x20,0x00,0xff,0xf7,0x93,0xff,0xc0,0x46,0xf8,0x06,0x00,0x20, +0x18,0x47,0xc0,0x46,0x70,0xb5,0x0a,0x4b,0x0a,0x4c,0xe4,0x1a,0xa4,0x10,0x0a,0xd0, +0x09,0x4a,0xa5,0x18,0xad,0x00,0xed,0x18,0x2b,0x68,0x01,0x3c,0x00,0xf0,0x0e,0xf8, +0x04,0x3d,0x00,0x2c,0xf8,0xd1,0x00,0xf0,0x49,0xf9,0x70,0xbc,0x01,0xbc,0x00,0x47, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x3f,0x18,0x47,0xc0,0x46, +0x70,0xb5,0x0f,0x4e,0x0f,0x4d,0xad,0x1b,0xad,0x10,0x07,0xd0,0x00,0x24,0xa3,0x00, +0xf3,0x58,0x01,0x34,0x00,0xf0,0x1c,0xf8,0xa5,0x42,0xf8,0xd1,0x00,0xf0,0x28,0xf9, +0x09,0x4e,0x0a,0x4d,0xad,0x1b,0xad,0x10,0x07,0xd0,0x00,0x24,0xa3,0x00,0xf3,0x58, +0x01,0x34,0x00,0xf0,0x0d,0xf8,0xa5,0x42,0xf8,0xd1,0x70,0xbc,0x01,0xbc,0x00,0x47, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x47,0xc0,0x46,0xf0,0xb5,0x83,0x07,0x4a,0xd0,0x54,0x1e,0x00,0x2a,0x44,0xd0, +0x0d,0x06,0x2d,0x0e,0x02,0x00,0x03,0x26,0x02,0xe0,0x1a,0x00,0x01,0x3c,0x3c,0xd3, +0x53,0x1c,0x15,0x70,0x33,0x42,0xf8,0xd1,0x03,0x2c,0x2d,0xd9,0xff,0x22,0x0a,0x40, +0x15,0x02,0x15,0x43,0x2a,0x04,0x15,0x43,0x0f,0x2c,0x16,0xd9,0x27,0x00,0x10,0x3f, +0x3f,0x09,0x3e,0x01,0xb4,0x46,0x1e,0x00,0x1a,0x00,0x10,0x36,0x66,0x44,0x15,0x60, +0x55,0x60,0x95,0x60,0xd5,0x60,0x10,0x32,0xb2,0x42,0xf8,0xd1,0x0f,0x22,0x01,0x37, +0x3f,0x01,0xdb,0x19,0x14,0x40,0x03,0x2c,0x0e,0xd9,0x26,0x1f,0xb6,0x08,0xb7,0x00, +0xbc,0x46,0x1a,0x00,0x1f,0x1d,0x67,0x44,0x20,0xc2,0xba,0x42,0xfc,0xd1,0x03,0x22, +0x01,0x36,0xb6,0x00,0x9b,0x19,0x14,0x40,0x00,0x2c,0x06,0xd0,0x09,0x06,0x1c,0x19, +0x09,0x0e,0x19,0x70,0x01,0x33,0x9c,0x42,0xfb,0xd1,0xf0,0xbc,0x02,0xbc,0x08,0x47, +0x14,0x00,0x03,0x00,0xc0,0xe7,0xc0,0x46,0xf0,0xb5,0xc6,0x46,0x00,0xb5,0x20,0x4c, +0x24,0x68,0x82,0xb0,0x01,0x94,0xa4,0x24,0x01,0x9d,0x64,0x00,0x2d,0x59,0x00,0x2d, +0x2d,0xd0,0x6c,0x68,0x1f,0x2c,0x30,0xdc,0x00,0x28,0x0b,0xd1,0x00,0x20,0x63,0x1c, +0x02,0x34,0xa4,0x00,0x6b,0x60,0x61,0x51,0x02,0xb0,0x04,0xbc,0x90,0x46,0xf0,0xbc, +0x02,0xbc,0x08,0x47,0x88,0x27,0xa6,0x00,0xae,0x19,0xf2,0x51,0x01,0x37,0xff,0x37, +0xbc,0x46,0x01,0x22,0xac,0x44,0x67,0x46,0xa2,0x40,0x3f,0x68,0x90,0x46,0x17,0x43, +0x62,0x46,0x17,0x60,0x84,0x27,0x7f,0x00,0xf3,0x51,0x02,0x28,0xde,0xd1,0x2b,0x00, +0x40,0x46,0x8d,0x33,0xff,0x33,0x1a,0x68,0x10,0x43,0x18,0x60,0xd6,0xe7,0x01,0x9d, +0x01,0x9e,0x4d,0x35,0xff,0x35,0x35,0x51,0xcb,0xe7,0x01,0x20,0x40,0x42,0xd3,0xe7, +0xf8,0x06,0x00,0x20,0xf0,0xb5,0x4e,0x46,0xde,0x46,0x57,0x46,0x45,0x46,0xe0,0xb5, +0x2e,0x4b,0x1b,0x68,0x83,0xb0,0x1a,0x00,0x00,0x93,0xa4,0x23,0x5b,0x00,0xd6,0x58, +0x01,0x22,0x01,0x90,0x0f,0x00,0x93,0x46,0x99,0x46,0x00,0x2e,0x31,0xd0,0x74,0x68, +0x65,0x1e,0x2e,0xd4,0xc4,0x23,0x5b,0x00,0x9a,0x46,0x01,0x34,0xa4,0x00,0x34,0x19, +0xb2,0x44,0x02,0xe0,0x04,0x3c,0x01,0x3d,0x23,0xd3,0x00,0x2f,0x04,0xd0,0x63,0x1c, +0xff,0x33,0x1b,0x68,0xbb,0x42,0xf5,0xd1,0x73,0x68,0x01,0x3b,0x22,0x68,0xab,0x42, +0x20,0xd0,0x00,0x23,0x23,0x60,0x00,0x2a,0xec,0xd0,0x73,0x68,0x98,0x46,0x5b,0x46, +0x51,0x46,0xab,0x40,0x09,0x68,0x19,0x42,0x16,0xd1,0x00,0xf0,0x29,0xf8,0x4a,0x46, +0x00,0x9b,0x9b,0x58,0x72,0x68,0x42,0x45,0x01,0xd1,0x9e,0x42,0xda,0xd0,0x1e,0x1e, +0xcd,0xd1,0x03,0xb0,0x3c,0xbc,0x90,0x46,0x99,0x46,0xa2,0x46,0xab,0x46,0xf0,0xbc, +0x01,0xbc,0x00,0x47,0x75,0x60,0xde,0xe7,0x30,0x00,0x21,0x00,0x8d,0x30,0xff,0x30, +0x00,0x68,0x80,0x31,0x09,0x68,0x18,0x42,0x03,0xd1,0x01,0x98,0x00,0xf0,0x08,0xf8, +0xdd,0xe7,0x08,0x00,0x00,0xf0,0x04,0xf8,0xd9,0xe7,0xc0,0x46,0xf8,0x06,0x00,0x20, +0x10,0x47,0xc0,0x46,0x04,0x4b,0x10,0xb5,0x00,0x2b,0x02,0xd0,0x03,0x48,0xff,0xf7, +0x93,0xfe,0x10,0xbc,0x01,0xbc,0x00,0x47,0x00,0x00,0x00,0x00,0x25,0x04,0x00,0x20, +0xf8,0xb5,0xc0,0x46,0xf8,0xbc,0x08,0xbc,0x9e,0x46,0x70,0x47,0xf8,0xb5,0xc0,0x46, +0xf8,0xbc,0x08,0xbc,0x9e,0x46,0x70,0x47,0x00,0x00,0x00,0x00,0x08,0xfa,0xff,0x7f, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x07,0x00,0x20,0x00,0x00,0x00,0x00, +0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x07,0x00,0x20,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xfc,0x09,0x00,0x20,0x64,0x0a,0x00,0x20,0xcc,0x0a,0x00,0x20, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -120,9 +121,9 @@ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x33,0xcd,0xab,0x34,0x12,0x6d,0xe6, -0xec,0xde,0x05,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0e,0x33,0xcd,0xab,0x34,0x12,0x6d,0xe6,0xec,0xde,0x05,0x00,0x0b,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -176,10 +177,9 @@ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xc9,0x00,0x00,0x20,0x99,0x00,0x00,0x20,0x91,0x06,0x00,0x20,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x20,0x99,0x00,0x00,0x20, +0xb5,0x06,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/contrib/loaders/flash/cc2538/flash.c b/contrib/loaders/flash/cc2538/flash.c index 390db2f31..65987b7c1 100644 --- a/contrib/loaders/flash/cc2538/flash.c +++ b/contrib/loaders/flash/cc2538/flash.c @@ -49,14 +49,16 @@ struct rom_api { unsigned long ulCount); } *ROM = (struct rom_api *)0x00000048; -extern uint32_t flash_sector_erase(uint32_t sector_address) +extern uint32_t flash_sector_erase(uint32_t sector) { long ret; bool already_erased = true; int i; + uint32_t address = flash_sector_to_address(sector); + for (i = 0; i < FLASH_ERASE_SIZE; i += 4) { - if ((*(uint32_t *)(sector_address + i)) != 0xffffffff) { + if ((*(uint32_t *)(address + i)) != 0xffffffff) { already_erased = false; break; } @@ -64,7 +66,7 @@ extern uint32_t flash_sector_erase(uint32_t sector_address) if (already_erased) return 0; - ret = ROM->PageErase(sector_address, FLASH_ERASE_SIZE); + ret = ROM->PageErase(address, FLASH_ERASE_SIZE); if (ret == -1) return 0x101; if (ret == -2) @@ -85,7 +87,7 @@ extern uint32_t flash_bank_erase(void) int num_sectors = ROM->GetFlashSize() / FLASH_ERASE_SIZE; for (i = num_sectors - 1; i >= 0; i--) { - ret = flash_sector_erase(flash_sector_to_address(i)); + ret = flash_sector_erase(i); if (ret != 0) return ret; } diff --git a/contrib/loaders/flash/cc2538/flash.h b/contrib/loaders/flash/cc2538/flash.h index 8c4658f8c..ad59113c3 100644 --- a/contrib/loaders/flash/cc2538/flash.h +++ b/contrib/loaders/flash/cc2538/flash.h @@ -44,8 +44,9 @@ #define FLASH_ERASE_SIZE 2048 #define FLASH_MAX_SECTOR_COUNT 256 +#define FLASH_MAX_BYTES (FLASH_ERASE_SIZE * FLASH_MAX_SECTOR_COUNT) -extern uint32_t flash_sector_erase(uint32_t sector_address); +extern uint32_t flash_sector_erase(uint32_t sector); extern uint32_t flash_bank_erase(void); extern uint32_t flash_program(uint8_t *data_buffer, uint32_t address, uint32_t count); @@ -53,9 +54,8 @@ extern uint32_t flash_program(uint8_t *data_buffer, uint32_t address, static inline uint32_t flash_address_to_sector(uint32_t address) { return ((address - FLASHMEM_BASE) / FLASH_ERASE_SIZE); }; - static inline uint32_t flash_sector_to_address(uint32_t sector) { - return ((sector * FLASH_ERASE_SIZE) + FLASHMEM_BASE); + return (FLASHMEM_BASE + (sector * FLASH_ERASE_SIZE)); }; #endif /* #ifndef OPENOCD_LOADERS_FLASH_CC2538_FLASH_H */ diff --git a/contrib/loaders/flash/cc2538/flashloader.c b/contrib/loaders/flash/cc2538/flashloader.c index a3ff09fe1..b2d52a86d 100644 --- a/contrib/loaders/flash/cc2538/flashloader.c +++ b/contrib/loaders/flash/cc2538/flashloader.c @@ -74,7 +74,11 @@ uint32_t flashloader_erase_sectors(uint32_t address, uint32_t byte_count) uint32_t status; uint32_t idx; - /* Floor address to the start of the sector and convert to sector number */ + if (address < FLASHMEM_BASE || + (address + byte_count) > (FLASHMEM_BASE + FLASH_MAX_BYTES)) + return STATUS_FAILED_INVALID_ARGUMENTS; + + /* Convert address and count to range of sectors */ first_sector_idx = flash_address_to_sector(address); last_sector_idx = flash_address_to_sector(address + byte_count - 1); @@ -83,7 +87,7 @@ uint32_t flashloader_erase_sectors(uint32_t address, uint32_t byte_count) /* Only erase sectors that haven't already been erased */ if (g_is_erased[idx] == false) { - status = flash_sector_erase(flash_sector_to_address(idx)); + status = flash_sector_erase(idx); if (status != 0) { status = (STATUS_FAILED_SECTOR_ERASE | ((idx << STATUS_EXT_INFO_S) & STATUS_EXT_INFO_M) | @@ -97,9 +101,12 @@ uint32_t flashloader_erase_sectors(uint32_t address, uint32_t byte_count) return STATUS_OK; } -uint32_t flashloader_program(uint8_t *src, uint32_t address, - uint32_t byte_count) +uint32_t flashloader_program(uint8_t *src, uint32_t address, uint32_t byte_count) { + if (address < FLASHMEM_BASE || + (address + byte_count) > (FLASHMEM_BASE + FLASH_MAX_BYTES)) + return STATUS_FAILED_INVALID_ARGUMENTS; + uint32_t status = flash_program(src, address, byte_count); if (status != 0) { status = (STATUS_FAILED_PROGRAM | diff --git a/contrib/loaders/flash/cc2538/flashloader.h b/contrib/loaders/flash/cc2538/flashloader.h index 075b58fc6..e4a7eb092 100644 --- a/contrib/loaders/flash/cc2538/flashloader.h +++ b/contrib/loaders/flash/cc2538/flashloader.h @@ -119,7 +119,7 @@ extern uint32_t flashloader_erase_all(void); * [16: 0] STATUS_FAILED_SECTOR_ERASE * */ -extern uint32_t flashloader_erase_sectors(uint32_t start_addr, +extern uint32_t flashloader_erase_sectors(uint32_t start_address, uint32_t byte_count); /* diff --git a/src/flash/nor/cc2538.c b/src/flash/nor/cc2538.c index e5f2cc856..e38e69b68 100644 --- a/src/flash/nor/cc2538.c +++ b/src/flash/nor/cc2538.c @@ -230,7 +230,7 @@ static int cc2538_erase(struct flash_bank *bank, int first, int last) return cc2538_mass_erase(bank); } - address = first * CC2538_SECTOR_LENGTH; + address = bank->base + first * CC2538_SECTOR_LENGTH; length = (last - first + 1) * CC2538_SECTOR_LENGTH; retval = cc2538_init(bank);