Quellcode durchsuchen

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

Conflicts:
	CMakeLists.txt
Brian Starkey vor 6 Monaten
Ursprung
Commit
c78503e11e
2 geänderte Dateien mit 21 neuen und 4 gelöschten Zeilen
  1. 2
    3
      CMakeLists.txt
  2. 19
    1
      gen_imghdr.py

+ 2
- 3
CMakeLists.txt Datei anzeigen

141
 	# Build the bootloader with the sections to fill in
141
 	# Build the bootloader with the sections to fill in
142
 	pico_set_linker_script(picowota ${PICOWOTA_SRC_DIR}/bootloader_shell.ld)
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
 	add_custom_target(${NAME}_hdr DEPENDS ${NAME})
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
 	add_custom_target(${COMBINED} ALL)
149
 	add_custom_target(${COMBINED} ALL)

+ 19
- 1
gen_imghdr.py Datei anzeigen

39
 parser.add_argument("ofile", help="Output header file (binary)")
39
 parser.add_argument("ofile", help="Output header file (binary)")
40
 parser.add_argument("-a", "--addr", help="Load address of the application image",
40
 parser.add_argument("-a", "--addr", help="Load address of the application image",
41
                     type=any_int, default=0x10004000)
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
 args = parser.parse_args()
45
 args = parser.parse_args()
43
 
46
 
44
 try:
47
 try:
46
 except:
49
 except:
47
     sys.exit("Could not open input file '{}'".format(args.ifile))
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
 size = len(idata)
68
 size = len(idata)
51
 crc = binascii.crc32(idata)
69
 crc = binascii.crc32(idata)
52
 
70
 

Laden…
Abbrechen
Speichern