Add MKS Robin Pro, MKS Robin Lite3 (#16163)
This commit is contained in:
		
							
								
								
									
										14
									
								
								buildroot/share/PlatformIO/ldscripts/mks_robin_lite3.ld
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								buildroot/share/PlatformIO/ldscripts/mks_robin_lite3.ld
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| MEMORY | ||||
| { | ||||
|   ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - 40 | ||||
|   rom (rx)  : ORIGIN = 0x08005000, LENGTH = 256K - 20K | ||||
| } | ||||
|  | ||||
| /* Provide memory region aliases for common.inc */ | ||||
| REGION_ALIAS("REGION_TEXT", rom); | ||||
| REGION_ALIAS("REGION_DATA", ram); | ||||
| REGION_ALIAS("REGION_BSS", ram); | ||||
| REGION_ALIAS("REGION_RODATA", rom); | ||||
|  | ||||
| /* Let common.inc handle the real work. */ | ||||
| INCLUDE common.inc | ||||
							
								
								
									
										14
									
								
								buildroot/share/PlatformIO/ldscripts/mks_robin_pro.ld
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								buildroot/share/PlatformIO/ldscripts/mks_robin_pro.ld
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| MEMORY | ||||
| { | ||||
|   ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40 | ||||
|   rom (rx)  : ORIGIN = 0x08007000, LENGTH = 512K - 28K | ||||
| } | ||||
|  | ||||
| /* Provide memory region aliases for common.inc */ | ||||
| REGION_ALIAS("REGION_TEXT", rom); | ||||
| REGION_ALIAS("REGION_DATA", ram); | ||||
| REGION_ALIAS("REGION_BSS", ram); | ||||
| REGION_ALIAS("REGION_RODATA", rom); | ||||
|  | ||||
| /* Let common.inc handle the real work. */ | ||||
| INCLUDE common.inc | ||||
							
								
								
									
										40
									
								
								buildroot/share/PlatformIO/scripts/mks_robin_lite3.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								buildroot/share/PlatformIO/scripts/mks_robin_lite3.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| import os | ||||
| Import("env") | ||||
|  | ||||
| # Relocate firmware from 0x08000000 to 0x08005000 | ||||
| for define in env['CPPDEFINES']: | ||||
|     if define[0] == "VECT_TAB_ADDR": | ||||
|         env['CPPDEFINES'].remove(define) | ||||
| env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000")) | ||||
|  | ||||
| custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld") | ||||
| for i, flag in enumerate(env["LINKFLAGS"]): | ||||
|     if "-Wl,-T" in flag: | ||||
|         env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script | ||||
|     elif flag == "-T": | ||||
|         env["LINKFLAGS"][i + 1] = custom_ld_script | ||||
|  | ||||
|  | ||||
| # Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin' | ||||
| def encrypt(source, target, env): | ||||
|     import sys | ||||
|  | ||||
|     key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] | ||||
|  | ||||
|     firmware = open(target[0].path, "rb") | ||||
|     robin = open(target[0].dir.path +'/mksLite3.bin', "wb") | ||||
|     length = os.path.getsize(target[0].path) | ||||
|     position = 0 | ||||
|     try: | ||||
|         while position < length: | ||||
|             byte = firmware.read(1) | ||||
|             if position >= 320 and position < 31040: | ||||
|                 byte = chr(ord(byte) ^ key[position & 31]) | ||||
|                 if sys.version_info[0] > 2: | ||||
|                     byte = bytes(byte, 'latin1') | ||||
|             robin.write(byte) | ||||
|             position += 1 | ||||
|     finally: | ||||
|         firmware.close() | ||||
|         robin.close() | ||||
| env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); | ||||
							
								
								
									
										39
									
								
								buildroot/share/PlatformIO/scripts/mks_robin_pro.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								buildroot/share/PlatformIO/scripts/mks_robin_pro.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import os | ||||
| Import("env") | ||||
|  | ||||
| # Relocate firmware from 0x08000000 to 0x08007000 | ||||
| for define in env['CPPDEFINES']: | ||||
|     if define[0] == "VECT_TAB_ADDR": | ||||
|         env['CPPDEFINES'].remove(define) | ||||
| env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) | ||||
|  | ||||
| custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_pro.ld") | ||||
| for i, flag in enumerate(env["LINKFLAGS"]): | ||||
|     if "-Wl,-T" in flag: | ||||
|         env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script | ||||
|     elif flag == "-T": | ||||
|         env["LINKFLAGS"][i + 1] = custom_ld_script | ||||
|  | ||||
| # Encrypt ${PROGNAME}.bin and save it as 'Robin.bin' | ||||
| def encrypt(source, target, env): | ||||
|     import sys | ||||
|  | ||||
|     key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] | ||||
|  | ||||
|     firmware = open(target[0].path, "rb") | ||||
|     robin = open(target[0].dir.path +'/Robin_pro.bin', "wb") | ||||
|     length = os.path.getsize(target[0].path) | ||||
|     position = 0 | ||||
|     try: | ||||
|         while position < length: | ||||
|             byte = firmware.read(1) | ||||
|             if position >= 320 and position < 31040: | ||||
|                 byte = chr(ord(byte) ^ key[position & 31]) | ||||
|                 if sys.version_info[0] > 2: | ||||
|                     byte = bytes(byte, 'latin1') | ||||
|             robin.write(byte) | ||||
|             position += 1 | ||||
|     finally: | ||||
|         firmware.close() | ||||
|         robin.close() | ||||
| env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); | ||||
		Reference in New Issue
	
	Block a user