99compiler_path = "{runtime.tools.gcc-arm-none-eabi.path}"
1010
1111class board_info_class ():
12- def __init__ (self , name , chip , vendor_name , product_name , variant , upload_baud_rate_list , toolchain = compiler_path , core = "tuya_open" ):
13- self .name = name
14- self .chip = chip
15- self .vendor_name = vendor_name
16- self .product_name = product_name
17- self .variant = variant
18- self .toolchain = toolchain
12+ def __init__ (self , name , chip , vendor_name , product_name , variant , upload_baud_rate_list , toolchain = compiler_path , toolchain_pre = "arm-none-eabi-" , core = "tuya_open" ):
13+ self .name = name # board name in boards.txt
14+ self .chip = chip # chip name
15+ self .vendor_name = vendor_name # board manufacturer name
16+ self .product_name = product_name # board name
17+ self .variant = variant # variant name
18+ self .toolchain = toolchain # toolchain
19+ self .toolchain_pre = toolchain_pre # toolchain prefix
1920 self .core = core
2021
2122 # upload baud rate
@@ -49,16 +50,15 @@ def build_header(bi):
4950
5051def build_toolchain (bi ):
5152 print ()
52- # compiler_path = bi.toolchain
5353 print (f"{ bi .name } .compiler.path={ bi .toolchain } " )
54- print (f"{ bi .name } .compiler.cmd.S={{compiler.path}}/bin/arm-none-eabi- gcc" )
55- print (f"{ bi .name } .compiler.cmd.c={{compiler.path}}/bin/arm-none-eabi- gcc" )
56- print (f"{ bi .name } .compiler.cmd.cpp={{compiler.path}}/bin/arm-none-eabi- g++" )
57- print (f"{ bi .name } .compiler.cmd.ar={{compiler.path}}/bin/arm-none-eabi- ar" )
54+ print (f"{ bi .name } .compiler.cmd.S={{compiler.path}}/bin/{ bi . toolchain_pre } gcc" )
55+ print (f"{ bi .name } .compiler.cmd.c={{compiler.path}}/bin/{ bi . toolchain_pre } gcc" )
56+ print (f"{ bi .name } .compiler.cmd.cpp={{compiler.path}}/bin/{ bi . toolchain_pre } g++" )
57+ print (f"{ bi .name } .compiler.cmd.ar={{compiler.path}}/bin/{ bi . toolchain_pre } ar" )
5858 if bi .chip == "t2" or bi .chip == "t3" :
59- print (f"{ bi .name } .compiler.cmd.ld={{compiler.path}}/bin/arm-none-eabi- gcc" )
59+ print (f"{ bi .name } .compiler.cmd.ld={{compiler.path}}/bin/{ bi . toolchain_pre } gcc" )
6060 else :
61- print (f"{ bi .name } .compiler.cmd.ld={{compiler.path}}/bin/arm-none-eabi- g++" )
61+ print (f"{ bi .name } .compiler.cmd.ld={{compiler.path}}/bin/{ bi . toolchain_pre } g++" )
6262
6363def build_flags (bi ):
6464 print ()
@@ -88,16 +88,18 @@ def build_flags(bi):
8888 ## combine
8989 print ()
9090 print (f"{ bi .name } .compiler.flags.ld=@{ vendor_path } /flags/ld_flags.txt" )
91- print (f"{ bi .name } .compiler.flags.libs=-L{ vendor_path } /libs @{ vendor_path } /flags/libs_flags.txt" )
92- ld_scripts_path = vendor_path + "/packager-tools/" + bi .chip + ".ld"
93- print (f"{ bi .name } .compiler.flags.ld_scripts=-Wl,--cref -Wl,-Map={{build.path}}/{{build.project_name}}.map -T{ ld_scripts_path } -o {{build.path}}/{{build.project_name}}.elf" )
91+ if bi .chip == 'esp32' :
92+ print (f"{ bi .name } .compiler.flags.libs=-L{ vendor_path } /libs -L{ vendor_path } /link_path/tuya_open_sdk/build/esp-idf/esp_system/ld -L{ vendor_path } /link_path/esp-idf/components/bt/controller/lib_esp32/esp32 -L{ vendor_path } /link_path/esp-idf/components/esp_coex/lib/esp32 -L{ vendor_path } /link_path/esp-idf/components/esp_phy/lib/esp32 -L{ vendor_path } /link_path/esp-idf/components/esp_rom/esp32/ld -L{ vendor_path } /link_path/esp-idf/components/esp_wifi/lib/esp32 -L{ vendor_path } /link_path/esp-idf/components/soc/esp32/ld @{ vendor_path } /flags/libs_flags.txt" )
93+ print (f"{ bi .name } .compiler.flags.ld_scripts=-Wl,--cref -Wl,-Map={{build.path}}/{{build.project_name}}.map -o {{build.path}}/{{build.project_name}}.elf" )
94+ else :
95+ print (f"{ bi .name } .compiler.flags.libs=-L{ vendor_path } /libs @{ vendor_path } /flags/libs_flags.txt" )
96+ ld_scripts_path = vendor_path + "/packager-tools/" + bi .chip + ".ld"
97+ print (f"{ bi .name } .compiler.flags.ld_scripts=-Wl,--cref -Wl,-Map={{build.path}}/{{build.project_name}}.map -T{ ld_scripts_path } -o {{build.path}}/{{build.project_name}}.elf" )
9498
9599def build_upload (bi ):
96100 print ()
97101 print (f"{ bi .name } .upload.tool=tyutool" )
98102 print (f"{ bi .name } .upload.tool.default=tyutool" )
99- # print(f"{bi.name}.upload.tool.baud_rate={bi.upload_baud_rate}")
100- # print(f"{bi.name}.upload.tool.baud_rate={{upload.speed}}")
101103
102104def build_monitor (bi ):
103105 print ()
@@ -112,8 +114,7 @@ def build_menu(bi):
112114 print (f"{ bi .name } .menu.UploadSpeed.{ baud_rate } ={ baud_rate } " )
113115 print (f"{ bi .name } .menu.UploadSpeed.{ baud_rate } .upload.speed={ baud_rate } " )
114116
115- def make_board (name , chip , vendor_name , product_name , variant , upload_baud_rate_list ):
116- board_info = board_info_class (name , chip , vendor_name , product_name , variant , upload_baud_rate_list )
117+ def make_board (board_info ):
117118
118119 build_header (board_info )
119120 build_menu (board_info )
@@ -133,13 +134,21 @@ def make_board(name, chip, vendor_name, product_name, variant, upload_baud_rate_
133134 build_menu_head ()
134135
135136 t2_upload_speed_list = [921600 , 115200 , 230400 , 460800 , 1500000 , 2000000 ]
136- make_board ("t2" , "t2" , "" , "T2" , "t2" , t2_upload_speed_list )
137+ t2_bi = board_info_class ("t2" , "t2" , "" , "T2" , "t2" , t2_upload_speed_list , compiler_path , "arm-none-eabi-" , "tuya_open" )
138+ make_board (t2_bi )
137139
138140 t3_upload_speed_list = [921600 , 115200 , 230400 , 460800 , 1500000 , 2000000 ]
139- make_board ("t3" , "t3" , "" , "T3" , "t3" , t3_upload_speed_list )
141+ t3_bi = board_info_class ("t3" , "t3" , "" , "T3" , "t3" , t3_upload_speed_list , compiler_path , "arm-none-eabi-" , "tuya_open" )
142+ make_board (t3_bi )
140143
141144 t5_upload_speed_list = [921600 , 115200 , 230400 , 460800 , 1500000 , 2000000 ]
142- make_board ("t5" , "t5" , "" , "T5" , "t5" , t5_upload_speed_list )
145+ t5_bi = board_info_class ("t5" , "t5" , "" , "T5" , "t5" , t5_upload_speed_list , compiler_path , "arm-none-eabi-" , "tuya_open" )
146+ make_board (t5_bi )
143147
144148 ln882h_upload_speed_list = [921600 , 115200 , 230400 , 460800 , 1500000 , 2000000 ]
145- make_board ("ln882h" , "ln882h" , "" , "LN882H" , "ln882h" , ln882h_upload_speed_list )
149+ ln882h_bi = board_info_class ("ln882h" , "ln882h" , "" , "LN882H" , "ln882h" , ln882h_upload_speed_list , compiler_path , "arm-none-eabi-" , "tuya_open" )
150+ make_board (ln882h_bi )
151+
152+ esp32_upload_speed_list = [921600 , 115200 , 230400 , 460800 , 1500000 , 2000000 ]
153+ esp_bi = board_info_class ("esp32" , "esp32" , "" , "ESP32" , "esp32" , esp32_upload_speed_list , "{runtime.tools.xtensa-esp-elf.path}" , "xtensa-esp32-elf-" , "tuya_open" )
154+ make_board (esp_bi )
0 commit comments