Browse Source

Merge branch 'pullreq3' of https://github.com/thingsconnected/picowota into thingsconnected-pullreq3

Conflicts:
	CMakeLists.txt
Brian Starkey 1 year ago
parent
commit
c78503e11e
2 changed files with 21 additions and 4 deletions
  1. 2
    3
      CMakeLists.txt
  2. 19
    1
      gen_imghdr.py

+ 2
- 3
CMakeLists.txt View File

@@ -141,10 +141,9 @@ function(picowota_build_combined NAME)
141 141
 	# Build the bootloader with the sections to fill in
142 142
 	pico_set_linker_script(picowota ${PICOWOTA_SRC_DIR}/bootloader_shell.ld)
143 143
 
144
-	# TODO: The hard-coded address here is a bit nasty
145 144
 	add_custom_target(${NAME}_hdr DEPENDS ${NAME})
146
-	add_custom_command(TARGET ${NAME}_hdr DEPENDS ${NAME}
147
-		COMMAND ${PICOWOTA_SRC_DIR}/gen_imghdr.py -a 0x1005B000 ${APP_BIN} ${APP_HDR_BIN}
145
+	add_custom_command(TARGET ${NAME}_hdr DEPENDS ${NAME} picowota
146
+		COMMAND ${PICOWOTA_SRC_DIR}/gen_imghdr.py --map ${PICOWOTA_BIN_DIR}/picowota.elf.map --section .app_bin ${APP_BIN} ${APP_HDR_BIN}
148 147
 	)
149 148
 
150 149
 	add_custom_target(${COMBINED} ALL)

+ 19
- 1
gen_imghdr.py View File

@@ -39,6 +39,9 @@ parser.add_argument("ifile", help="Input application binary (binary)")
39 39
 parser.add_argument("ofile", help="Output header file (binary)")
40 40
 parser.add_argument("-a", "--addr", help="Load address of the application image",
41 41
                     type=any_int, default=0x10004000)
42
+parser.add_argument("-m", "--map", help="Map file to scan for application image section")
43
+parser.add_argument("-s", "--section", help="Section name to look for in map file",
44
+                    default=".app_bin")
42 45
 args = parser.parse_args()
43 46
 
44 47
 try:
@@ -46,7 +49,22 @@ try:
46 49
 except:
47 50
     sys.exit("Could not open input file '{}'".format(args.ifile))
48 51
 
49
-vtor = args.addr
52
+if args.map:
53
+    vtor = None
54
+    with open(args.map) as mapfile:
55
+        for line in mapfile:
56
+            if line.startswith(args.section):
57
+                parts = line.split()
58
+                if len(parts)>1:
59
+                    vtor = int(parts[1],0)
60
+                    print('found address 0x%x for %s in %s'%(vtor,args.section,args.map))
61
+                    break
62
+
63
+    if vtor is None:
64
+        sys.exit("Could not find section {} in {}".format(args.section,args.map))
65
+else:
66
+    vtor = args.addr
67
+
50 68
 size = len(idata)
51 69
 crc = binascii.crc32(idata)
52 70
 

Loading…
Cancel
Save