diff --git a/Makefile b/Makefile index f1fecac..3b8cbd5 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,14 @@ -# make 编译并下载 +# make 编译并下载,成功后自动打包到 release/ +# make pack 仅打包(需已编译生成 jl_isd.fw) # make VERBOSE=1 显示编译详细过程 # make clean 清除编译临时文件 # +# USB 烧录(两套镜像都会生成,只烧其中一套): +# .\build.bat 或 .\build.bat nokey -> 烧不带 Key +# .\build.bat key -> 烧带 Key +# make BURN_KEY=1 与 build.bat key 相同 +# # 注意: Linux 下编译方式: # 1. 从 http://pkgman.jieliapp.com/doc/all 处找到下载链接 # 2. 下载后,解压到 /opt/jieli 目录下,保证 @@ -31,6 +37,11 @@ export PATH:=$(TOOL_DIR);$(PATH) FIXBAT := tools\utils\fixbat.exe # 用于处理 utf8->gbk 编码问题 POST_SCRIPT := cpu/br28/tools/download.bat RUN_POST_SCRIPT := cpu\br28\tools\download.bat +PACK_SCRIPT := powershell -NoProfile -ExecutionPolicy Bypass -File tools\pack_firmware.ps1 +# USB: 1/key/yes = flash keyed image; default = nokey +ifneq ($(filter 1 key yes,$(BURN_KEY)),) +export JL_BURN_KEY := 1 +endif else # Linux 下工具链位置 TOOL_DIR := /opt/jieli/pi32v2/bin @@ -53,6 +64,7 @@ export PATH:=$(TOOL_DIR):$(PATH) FIXBAT := touch # Linux下不需要处理 bat 编码问题 POST_SCRIPT := cpu/br28/tools/download.sh RUN_POST_SCRIPT := bash $(POST_SCRIPT) +PACK_SCRIPT := endif CC := $(TOOL_DIR)/$(CC) @@ -265,17 +277,9 @@ c_SRC_FILES := \ apps/common/audio/audio_utils.c \ apps/common/audio/decode/audio_key_tone.c \ apps/common/audio/decode/decode.c \ - apps/common/audio/demo/audio_demo.c \ - apps/common/audio/online_debug/aud_data_export.c \ - apps/common/audio/online_debug/aud_mic_dut.c \ - apps/common/audio/online_debug/aud_spatial_effect_dut.c \ - apps/common/audio/online_debug/audio_online_debug.c \ apps/common/audio/sine_make.c \ apps/common/audio/uartPcmSender.c \ - apps/common/audio/wm8978/iic.c \ - apps/common/audio/wm8978/wm8978.c \ apps/common/bt_common/bt_test_api.c \ - apps/common/cJSON/cJSON.c \ apps/common/config/app_config.c \ apps/common/config/bt_profile_config.c \ apps/common/config/ci_transport_uart.c \ @@ -285,35 +289,6 @@ c_SRC_FILES := \ apps/common/dev_manager/dev_manager.c \ apps/common/dev_manager/dev_reg.c \ apps/common/dev_manager/dev_update.c \ - apps/common/device/gSensor/SC7A20.c \ - apps/common/device/gSensor/STK8321.c \ - apps/common/device/gSensor/da230.c \ - apps/common/device/gSensor/gSensor_manage.c \ - apps/common/device/gSensor/mpu6050.c \ - apps/common/device/gx8002_npu/gx8002_enc/gx8002_enc.c \ - apps/common/device/gx8002_npu/gx8002_npu.c \ - apps/common/device/gx8002_npu/gx8002_npu_event_deal.c \ - apps/common/device/gx8002_npu/gx8002_upgrade/app_upgrade/gx_uart_upgrade_app.c \ - apps/common/device/gx8002_npu/gx8002_upgrade/app_upgrade/gx_uart_upgrade_tws.c \ - apps/common/device/gx8002_npu/gx8002_upgrade/gx_uart_upgrade.c \ - apps/common/device/gx8002_npu/gx8002_upgrade/gx_uart_upgrade_porting.c \ - apps/common/device/gx8002_npu/gx8002_upgrade/sdfile_upgrade/gx_uart_upgrade_sdfile.c \ - apps/common/device/gx8002_npu/gx8002_upgrade/spp_upgrade/gx_fifo.c \ - apps/common/device/gx8002_npu/gx8002_upgrade/spp_upgrade/gx_uart_upgrade_spp.c \ - apps/common/device/imu_sensor/icm_42670p/icm_42670p.c \ - apps/common/device/imu_sensor/icm_42670p/inv_imu_apex.c \ - apps/common/device/imu_sensor/icm_42670p/inv_imu_driver.c \ - apps/common/device/imu_sensor/icm_42670p/inv_imu_transport.c \ - apps/common/device/imu_sensor/imuSensor_manage.c \ - apps/common/device/imu_sensor/lsm6dsl/lsm6dsl.c \ - apps/common/device/imu_sensor/mpu6887/mpu6887p.c \ - apps/common/device/imu_sensor/mpu9250/mpu9250.c \ - apps/common/device/imu_sensor/qmi8658/qmi8658c.c \ - apps/common/device/imu_sensor/sh3001/sh3001.c \ - apps/common/device/in_ear_detect/in_ear_detect.c \ - apps/common/device/in_ear_detect/in_ear_manage.c \ - apps/common/device/ir_sensor/ir_manage.c \ - apps/common/device/ir_sensor/jsa1221.c \ apps/common/device/key/adkey.c \ apps/common/device/key/adkey_rtcvdd.c \ apps/common/device/key/ctmu_touch_key.c \ @@ -323,7 +298,6 @@ c_SRC_FILES := \ apps/common/device/key/touch_key.c \ apps/common/device/key/uart_key.c \ apps/common/device/norflash/norflash_sfc.c \ - apps/common/device/ntc/ntc_det.c \ apps/common/device/usb/device/cdc.c \ apps/common/device/usb/device/descriptor.c \ apps/common/device/usb/device/hid.c \ @@ -345,43 +319,11 @@ c_SRC_FILES := \ apps/common/device/usb/host/usb_storage.c \ apps/common/device/usb/usb_config.c \ apps/common/device/usb/usb_host_config.c \ - apps/common/ezxml/ezxml.c \ - apps/common/ezxml/ezxml_example.c \ apps/common/fat_nor/cfg_private.c \ apps/common/fat_nor/virfat_flash.c \ apps/common/file_operate/file_bs_deal.c \ apps/common/file_operate/file_manager.c \ - apps/common/icsd/adt/icsd_adt.c \ - apps/common/icsd/adt/icsd_adt_app.c \ - apps/common/icsd/anc/icsd_anc_app.c \ - apps/common/icsd/anc/icsd_anc_board.c \ - apps/common/icsd/anc/icsd_anc_data.c \ - apps/common/jl_kws/jl_kws_algo.c \ - apps/common/jl_kws/jl_kws_audio.c \ - apps/common/jl_kws/jl_kws_event.c \ - apps/common/jl_kws/jl_kws_main.c \ - apps/common/music/breakpoint.c \ - apps/common/music/music_decrypt.c \ - apps/common/music/music_id3.c \ - apps/common/music/music_player.c \ apps/common/temp_trim/dtemp_pll_trim.c \ - apps/common/test/fs_test.c \ - apps/common/test/os_test.c \ - apps/common/third_party_profile/Tecent_LL/tecent_ll_demo/ll_demo.c \ - apps/common/third_party_profile/Tecent_LL/tecent_ll_demo/ll_task.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_import.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_llsync_data.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_llsync_device.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_llsync_event.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_llsync_ota.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_service.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_template.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_utils_base64.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_utils_crc.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_utils_hmac.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_utils_log.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_utils_md5.c \ - apps/common/third_party_profile/Tecent_LL/tecent_protocol/ble_qiot_utils_sha1.c \ apps/common/third_party_profile/common/3th_profile_api.c \ apps/common/third_party_profile/common/custom_cfg.c \ apps/common/third_party_profile/common/mic_rec.c \ @@ -398,7 +340,6 @@ c_SRC_FILES := \ apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_anc_voice_key.c \ apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_bt_name_setting.c \ apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_eq_setting.c \ - apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_hearing_aid_setting.c \ apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_high_low_vol_setting.c \ apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_key_setting.c \ apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_led_setting.c \ @@ -415,85 +356,26 @@ c_SRC_FILES := \ apps/common/third_party_profile/jieli/JL_rcsp/rcsp_updata/rcsp_adv_user_update.c \ apps/common/third_party_profile/jieli/JL_rcsp/rcsp_updata/rcsp_ch_loader_download.c \ apps/common/third_party_profile/jieli/JL_rcsp/rcsp_updata/rcsp_user_update.c \ - apps/common/third_party_profile/jieli/le_hogp.c \ apps/common/third_party_profile/jieli/online_db/online_db_deal.c \ apps/common/third_party_profile/jieli/online_db/spp_online_db.c \ - apps/common/third_party_profile/jieli/trans_data_demo/le_trans_data.c \ - apps/common/third_party_profile/jieli/trans_data_demo/spp_trans_data.c \ - apps/common/third_party_profile/jieli/wireless_mic/le_wireless_mic_client.c \ - apps/common/third_party_profile/jieli/wireless_mic/le_wireless_mic_server.c \ - apps/common/third_party_profile/tuya_protocol/app/demo/tuya_ble_app_demo.c \ - apps/common/third_party_profile/tuya_protocol/app/demo/tuya_ota.c \ - apps/common/third_party_profile/tuya_protocol/app/product_test/tuya_ble_app_production_test.c \ - apps/common/third_party_profile/tuya_protocol/app/uart_common/tuya_ble_app_uart_common_handler.c \ - apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/aes.c \ - apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/ccm.c \ - apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/hmac.c \ - apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/md5.c \ - apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/sha1.c \ - apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/sha256.c \ - apps/common/third_party_profile/tuya_protocol/port/tuya_ble_port.c \ - apps/common/third_party_profile/tuya_protocol/port/tuya_ble_port_JL.c \ - apps/common/third_party_profile/tuya_protocol/port/tuya_ble_port_peripheral.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_api.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_bulk_data.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_data_handler.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_event.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_event_handler.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_event_handler_weak.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_feature_weather.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_gatt_send_queue.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_heap.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_main.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_mem.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_mutli_tsf_protocol.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_queue.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_storage.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_unix_time.c \ - apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_utils.c \ - apps/common/ui/lcd_simple/lcd_simple_api.c \ - apps/common/ui/lcd_simple/ui.c \ - apps/common/ui/lcd_simple/ui_mainmenu.c \ apps/common/update/testbox_update.c \ apps/common/update/update.c \ apps/common/update/update_tws.c \ apps/common/update/update_tws_new.c \ - apps/earphone/aec/br28/audio_aec.c \ - apps/earphone/aec/br28/audio_aec_demo.c \ - apps/earphone/aec/br28/audio_aec_dms.c \ - apps/earphone/aec/br28/audio_aec_online.c \ - apps/earphone/aec/br28/audio_cvp_3mic.c \ - apps/earphone/aec/br28/audio_cvp_ais_3mic.c \ - apps/earphone/app_ancbox.c \ - apps/earphone/app_anctool.c \ apps/earphone/app_main.c \ - apps/earphone/app_protocol_deal.c \ apps/earphone/app_task_switch.c \ apps/earphone/app_testbox.c \ - apps/earphone/audio_enc_mpt_cvp_ctr.c \ - apps/earphone/audio_enc_mpt_self.c \ apps/earphone/ble_adv.c \ - apps/earphone/board/br28/board_jl7016g_hybrid.c \ - apps/earphone/board/br28/board_jl7018f_demo.c \ - apps/earphone/board/br28/board_jl701n_anc.c \ - apps/earphone/board/br28/board_jl701n_btemitter.c \ apps/earphone/board/br28/board_jl701n_demo.c \ apps/earphone/bt_auto_test.c \ apps/earphone/bt_background.c \ apps/earphone/bt_ble.c \ - apps/earphone/bt_ble_hid.c \ - apps/earphone/bt_emitter.c \ - apps/earphone/bt_tws.c \ apps/earphone/default_event_handler.c \ apps/earphone/dual_update_demo.c \ apps/earphone/earphone.c \ apps/earphone/eartch_event_deal.c \ - apps/earphone/font/fontinit.c \ apps/earphone/idle.c \ apps/earphone/key_event_deal.c \ - apps/earphone/kws_voice_event_deal.c \ - apps/earphone/linein/linein.c \ - apps/earphone/ll_sync_demo/ll_sync_demo.c \ apps/earphone/log_config/app_config.c \ apps/earphone/log_config/lib_btctrler_config.c \ apps/earphone/log_config/lib_btstack_config.c \ @@ -501,53 +383,33 @@ c_SRC_FILES := \ apps/earphone/log_config/lib_media_config.c \ apps/earphone/log_config/lib_system_config.c \ apps/earphone/log_config/lib_update_config.c \ - apps/earphone/music/sd_music.c \ - apps/earphone/pbg_demo.c \ apps/earphone/pc/pc.c \ apps/earphone/power_manage/app_charge.c \ - apps/earphone/power_manage/app_chargestore.c \ apps/earphone/power_manage/app_power_manage.c \ - apps/earphone/power_manage/app_umidigi_chargestore.c \ apps/earphone/rcsp/jl_phone_app.c \ apps/earphone/rcsp/rcsp_adv.c \ apps/earphone/tone_table.c \ - apps/earphone/trans_data_demo/trans_data_demo.c \ - apps/earphone/tuya/tuya_app.c \ - apps/earphone/tuya/tuya_demo.c \ - apps/earphone/ui/lcd_simple/my_demo.c \ apps/earphone/ui_manage.c \ apps/earphone/user_cfg.c \ apps/earphone/version.c \ - apps/earphone/vol_sync.c \ - apps/earphone/wireless_mic/app_main_wireless_mic.c \ - apps/earphone/wireless_mic/audio/adapter_adc.c \ - apps/earphone/wireless_mic/audio/adapter_media.c \ - apps/earphone/wireless_mic/audio/wireless/adapter_wireless_dec.c \ - apps/earphone/wireless_mic/audio/wireless/adapter_wireless_enc.c \ - apps/earphone/wireless_mic/bt/bt_edr_fun.c \ - apps/earphone/wireless_mic/bt/bt_status_event.c \ - apps/earphone/wireless_mic/idev/adapter_idev.c \ - apps/earphone/wireless_mic/idev/idev_bt/adapter_idev_bt.c \ - apps/earphone/wireless_mic/idev/idev_bt/idev_ble/adapter_idev_ble.c \ - apps/earphone/wireless_mic/idev/idev_mic/adapter_idev_mic.c \ - apps/earphone/wireless_mic/odev/adapter_odev.c \ - apps/earphone/wireless_mic/odev/odev_bt/adapter_odev_bt.c \ - apps/earphone/wireless_mic/odev/odev_bt/odev_ble/adapter_odev_ble.c \ - apps/earphone/wireless_mic/odev/odev_bt/odev_ble/odev_ble_wireless.c \ - apps/earphone/wireless_mic/odev/odev_bt/odev_edr/adapter_odev_edr.c \ - apps/earphone/wireless_mic/odev/odev_dac/adapter_odev_dac.c \ - apps/earphone/wireless_mic/process/adapter_process.c \ + apps/usr_jb_proto/Protocol/jb_product.c \ + apps/usr_jb_proto/Protocol/jb_protocol.c \ + apps/usr_jb_proto/Utils/jb_common.c \ + apps/usr_jb_proto/Utils/jb_ringbuffer.c \ + apps/usr_jb_proto/usr_jb_main.c \ + apps/usr_periph/usr_rtc.c \ + apps/usr_le_code/ble_proto.c \ + apps/usr_le_code/bleproto.c \ + apps/usr_le_code/bleproto_packer.c \ + apps/usr_le_code/thirdpart/mjson/mjson.c \ + apps/usr_le_code/usr_le_adv.c \ + apps/usr_le_code/usr_le_recieve.c \ cpu/br28/adc_api.c \ - cpu/br28/aec_tool.c \ cpu/br28/app_audio.c \ - cpu/br28/audio_anc.c \ - cpu/br28/audio_anc_fade_ctr.c \ - cpu/br28/audio_anc_mult_scene.c \ cpu/br28/audio_capture.c \ cpu/br28/audio_codec_clock.c \ cpu/br28/audio_common/audio_mic_codec.c \ cpu/br28/audio_cvp_dut.c \ - cpu/br28/audio_cvp_sync.c \ cpu/br28/audio_dec.c \ cpu/br28/audio_dec/audio_dec_file.c \ cpu/br28/audio_dec/audio_dec_iis.c \ @@ -555,17 +417,8 @@ c_SRC_FILES := \ cpu/br28/audio_dec/audio_dec_pcm.c \ cpu/br28/audio_dec/audio_usb_mic.c \ cpu/br28/audio_dec_eff.c \ - cpu/br28/audio_demo/audio_adc_demo.c \ - cpu/br28/audio_demo/audio_dac_demo.c \ - cpu/br28/audio_demo/audio_fft_demo.c \ - cpu/br28/audio_demo/audio_matrix_demo.c \ - cpu/br28/audio_demo/audio_wind_detect_demo.c \ - cpu/br28/audio_effect_develop.c \ cpu/br28/audio_enc.c \ cpu/br28/audio_general.c \ - cpu/br28/audio_hearing/audio_hearing_aid.c \ - cpu/br28/audio_hearing/audio_hearing_aid_lp.c \ - cpu/br28/audio_hearing/audio_sidetone.c \ cpu/br28/audio_link.c \ cpu/br28/audio_sync.c \ cpu/br28/charge.c \ @@ -573,7 +426,6 @@ c_SRC_FILES := \ cpu/br28/clock_manager.c \ cpu/br28/eq_config.c \ cpu/br28/hw_fft.c \ - cpu/br28/icsd_anc_user.c \ cpu/br28/iic_hw.c \ cpu/br28/iic_soft.c \ cpu/br28/irflt.c \ @@ -594,43 +446,13 @@ c_SRC_FILES := \ cpu/br28/pwm_led.c \ cpu/br28/rdec.c \ cpu/br28/setup.c \ - cpu/br28/smart_voice/aispeech_asr.c \ - cpu/br28/smart_voice/jl_kws_platform.c \ - cpu/br28/smart_voice/kws_event.c \ - cpu/br28/smart_voice/nn_vad.c \ - cpu/br28/smart_voice/smart_voice_config.c \ - cpu/br28/smart_voice/smart_voice_core.c \ - cpu/br28/smart_voice/user_asr.c \ - cpu/br28/smart_voice/vad_clock_trim.c \ - cpu/br28/smart_voice/vad_mic.c \ - cpu/br28/smart_voice/voice_mic_data.c \ cpu/br28/sound_device.c \ - cpu/br28/spatial_effect/spatial_effect.c \ - cpu/br28/spatial_effect/spatial_effect_imu.c \ - cpu/br28/spatial_effect/spatial_effect_test.c \ - cpu/br28/spatial_effect/spatial_effect_tws.c \ - cpu/br28/spatial_effect/spatial_imu_trim.c \ cpu/br28/spi.c \ cpu/br28/tone_player.c \ cpu/br28/tws_audio.c \ cpu/br28/uart_dev.c \ - cpu/br28/umidigi_chargestore.c \ - apps/usr_jb_proto/Protocol/jb_product.c \ - apps/usr_jb_proto/Protocol/jb_protocol.c \ - apps/usr_jb_proto/Utils/jb_common.c \ - apps/usr_jb_proto/Utils/jb_ringbuffer.c \ - apps/usr_jb_proto/usr_jb_main.c \ - apps/usr_periph/usr_rtc.c \ - apps/usr_le_code/ble_proto.c \ - apps/usr_le_code/bleproto.c \ - apps/usr_le_code/bleproto_packer.c \ - apps/usr_le_code/thirdpart/mjson/mjson.c \ - apps/usr_le_code/usr_le_adv.c \ - apps/usr_le_code/usr_le_recieve.c \ + cpu/br28/uart_test.c - - -# 需要编译的 .S 文件 S_SRC_FILES := \ apps/earphone/sdk_version.z.S \ @@ -789,7 +611,7 @@ LINK_AT ?= 1 # 表示下面的不是一个文件的名字,无论是否存在 all, clean, pre_build 这样的文件 # 还是要执行命令 # see: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html -.PHONY: all clean pre_build +.PHONY: all clean pre_build pack # 不要使用 make 预设置的规则 # see: https://www.gnu.org/software/make/manual/html_node/Suffix-Rules.html @@ -798,6 +620,18 @@ LINK_AT ?= 1 all: pre_build $(OUT_ELF) $(info +POST-BUILD) $(QUITE) $(RUN_POST_SCRIPT) sdk +ifneq ($(PACK_SCRIPT),) + $(info +PACK-FIRMWARE) + $(QUITE) $(PACK_SCRIPT) +endif + +pack: + $(info +PACK-FIRMWARE) +ifneq ($(PACK_SCRIPT),) + $(QUITE) $(PACK_SCRIPT) +else + $(error pack script is Windows-only) +endif pre_build: diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..fca5f41 --- /dev/null +++ b/build.bat @@ -0,0 +1,30 @@ +@echo off +chcp 65001 >nul +cd /d "%~dp0" +setlocal EnableDelayedExpansion + +REM JieLi make / mkdir_win / rm / fixbat live in tools\utils, not in system PATH +set "PATH=%~dp0tools\utils;%PATH%" + +REM USB burn: default WITH key. build.bat nokey to burn without key +set "JL_BURN_KEY=1" +set "MAKE_ARGS=" + +for %%A in (%*) do ( + if /i "%%~A"=="key" ( + set "JL_BURN_KEY=1" + ) else if /i "%%~A"=="nokey" ( + set "JL_BURN_KEY=0" + ) else ( + set "MAKE_ARGS=!MAKE_ARGS! %%~A" + ) +) + +if "!JL_BURN_KEY!"=="1" ( + echo [build] USB burn: WITH key +) else ( + echo [build] USB burn: NO key +) + +make !MAKE_ARGS! +exit /b !errorlevel! diff --git a/tools/pack_firmware.bat b/tools/pack_firmware.bat new file mode 100644 index 0000000..957c19b --- /dev/null +++ b/tools/pack_firmware.bat @@ -0,0 +1,12 @@ +@echo off +chcp 65001 >nul +cd /d "%~dp0" +powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0pack_firmware.ps1" +if errorlevel 1 ( + echo. + echo pack failed. + pause + exit /b 1 +) +echo. +pause \ No newline at end of file diff --git a/tools/pack_firmware.ps1 b/tools/pack_firmware.ps1 new file mode 100644 index 0000000..52395dc --- /dev/null +++ b/tools/pack_firmware.ps1 @@ -0,0 +1,168 @@ +# pack_firmware.ps1 +# Extract JieLi burn files and zip as Project_Version_Date. +# ASCII only: Windows PowerShell 5.1 mis-parses UTF-8 without BOM. +# +# Usage: +# .\build.bat - build + download.bat + pack +# make pack - pack only +# tools\pack_firmware.bat + +[CmdletBinding()] +param( + [string]$ProjectName = "JBao_Heat_Pad", + [string]$SdkRoot = "" +) + +$ErrorActionPreference = "Stop" +$exitCode = 0 + +try { + +if ([string]::IsNullOrWhiteSpace($SdkRoot)) { + $SdkRoot = Split-Path -Parent $PSScriptRoot +} + +$VersionHeader = Join-Path $SdkRoot "apps\usr_jb_proto\Protocol\jb_product.h" +$DownloadDir = Join-Path $SdkRoot "cpu\br28\tools\download\earphone" +$ReleaseRoot = Join-Path $SdkRoot "release" + +function Read-FwVersion { + param([string]$HeaderPath) + + if (-not (Test-Path -LiteralPath $HeaderPath)) { + throw "version header not found: $HeaderPath" + } + + $text = Get-Content -LiteralPath $HeaderPath -Raw -Encoding UTF8 + $major = $null + $minor = $null + $patch = $null + + if ($text -match '(?m)^\s*#define\s+JB_MCU_SW_VERSION_MAJOR\s+(\d+)') { + $major = $Matches[1] + } + if ($text -match '(?m)^\s*#define\s+JB_MCU_SW_VERSION_MINOR\s+(\d+)') { + $minor = $Matches[1] + } + if ($text -match '(?m)^\s*#define\s+JB_MCU_SW_VERSION_PATCH\s+(\d+)') { + $patch = $Matches[1] + } + + if (($null -eq $major) -or ($null -eq $minor) -or ($null -eq $patch)) { + throw "cannot parse JB_MCU_SW_VERSION_* from $HeaderPath" + } + + return "V$major.$minor.$patch" +} + +$PackItems = @( + @{ Name = "jl_isd_nokey.fw"; Fallback = "jl_isd.fw"; Suffix = "_nokey_burner.fw"; Required = $true; NoteKey = "burner_nokey" }, + @{ Name = "update_nokey.ufw"; Fallback = "update.ufw"; Suffix = "_nokey_app_ota.ufw"; Required = $false; NoteKey = "app_nokey" }, + @{ Name = "db_update_data_nokey.bin"; Fallback = "db_update_data.bin"; Suffix = "_nokey_gateway_ota.bin"; Required = $false; NoteKey = "gw_nokey" }, + @{ Name = "jl_isd_key.fw"; Fallback = ""; Suffix = "_key_burner.fw"; Required = $false; NoteKey = "burner_key" }, + @{ Name = "update_key.ufw"; Fallback = ""; Suffix = "_key_app_ota.ufw"; Required = $false; NoteKey = "app_key" }, + @{ Name = "db_update_data_key.bin"; Fallback = ""; Suffix = "_key_gateway_ota.bin"; Required = $false; NoteKey = "gw_key" } +) + +$NoteZh = @{} +$notesFile = Join-Path $PSScriptRoot "pack_notes_zh.txt" +Get-Content -LiteralPath $notesFile -Encoding UTF8 | ForEach-Object { + if ($_ -match '^([^|]+)\|(.*)$') { + $NoteZh[$Matches[1].Trim()] = $Matches[2].Trim() + } +} + +Write-Host "========================================" +Write-Host " pack firmware" +Write-Host "========================================" + +$version = Read-FwVersion -HeaderPath $VersionHeader +$dateStr = Get-Date -Format "yyMMddHHmm" +$pkgName = "${ProjectName}_${version}_${dateStr}" + +Write-Host "project : $ProjectName" +Write-Host "version : $version (from jb_product.h)" +Write-Host "date : $dateStr" +Write-Host "source : $DownloadDir" +Write-Host "" + +if (-not (Test-Path -LiteralPath $DownloadDir)) { + throw "download dir not found, compile the project first: $DownloadDir" +} + +$copied = @() +foreach ($item in $PackItems) { + $src = Join-Path $DownloadDir $item.Name + if (-not (Test-Path -LiteralPath $src) -and $item.Fallback) { + $src = Join-Path $DownloadDir $item.Fallback + } + if (Test-Path -LiteralPath $src) { + $item.Src = $src + $item.Dest = $pkgName + $item.Suffix + $copied += $item + continue + } + if ($item.Required) { + throw "missing required file: $($item.Name); please build the firmware first." + } + Write-Host "[skip] $($item.Name) not generated" +} + +if ($copied.Count -eq 0) { + throw "no firmware files found in $DownloadDir" +} + +$pkgDir = Join-Path $ReleaseRoot $pkgName +if (Test-Path -LiteralPath $pkgDir) { + Remove-Item -LiteralPath $pkgDir -Recurse -Force +} +New-Item -ItemType Directory -Path $pkgDir -Force | Out-Null + +foreach ($item in $copied) { + Copy-Item -LiteralPath $item.Src -Destination (Join-Path $pkgDir $item.Dest) -Force + $size = (Get-Item -LiteralPath $item.Src).Length + Write-Host ("[copy] {0,-28} -> {1} ({2} bytes)" -f (Split-Path $item.Src -Leaf), $item.Dest, $size) +} + +$fileList = New-Object System.Collections.Generic.List[string] +foreach ($item in $copied) { + $note = $NoteZh[$item.NoteKey] + [void]$fileList.Add((" {0}" -f $item.Dest)) + [void]$fileList.Add((" {0}" -f $note)) +} + +$tplPath = Join-Path $PSScriptRoot "pack_readme_zh.txt" +$readme = Get-Content -LiteralPath $tplPath -Raw -Encoding UTF8 +$readme = $readme.Replace("{{PKG_NAME}}", $pkgName) +$readme = $readme.Replace("{{PROJECT}}", $ProjectName) +$readme = $readme.Replace("{{VERSION}}", $version) +$readme = $readme.Replace("{{DATE}}", (Get-Date -Format "yyyy-MM-dd HH:mm:ss")) +$readme = $readme.Replace("{{FILE_LIST}}", ($fileList -join "`r`n")) +$readme = $readme -replace "`n", "`r`n" +$readme = $readme -replace "`r`r`n", "`r`n" +[System.IO.File]::WriteAllText( + (Join-Path $pkgDir "README.txt"), + $readme, + [System.Text.UTF8Encoding]::new($true) +) + +$zipPath = Join-Path $ReleaseRoot "$pkgName.zip" +if (Test-Path -LiteralPath $zipPath) { + Remove-Item -LiteralPath $zipPath -Force +} + +Compress-Archive -Path (Join-Path $pkgDir "*") -DestinationPath $zipPath -CompressionLevel Optimal + +Write-Host "" +Write-Host "folder : $pkgDir" +Write-Host "zip : $zipPath" +Write-Host "done." +Write-Host "========================================" + +} catch { + Write-Host "" + Write-Host "pack failed: $($_.Exception.Message)" + $exitCode = 1 +} + +exit $exitCode diff --git a/tools/pack_notes_zh.txt b/tools/pack_notes_zh.txt new file mode 100644 index 0000000..605f28a --- /dev/null +++ b/tools/pack_notes_zh.txt @@ -0,0 +1,6 @@ +burner_nokey|不带 Key:产线批量烧录器镜像(调试、未加密芯片) +app_nokey|不带 Key:手机 APP / 小程序 OTA(UFW) +gw_nokey|不带 Key:55AA 服务器 OTA / 网关 OTA(杰理双备份包) +burner_key|带 Key:产线批量烧录器镜像(烧录器需配置同一把 key) +app_key|带 Key:手机 APP / 小程序 OTA(UFW) +gw_key|带 Key:55AA 服务器 OTA / 网关 OTA(杰理双备份包) diff --git a/tools/pack_readme_zh.txt b/tools/pack_readme_zh.txt new file mode 100644 index 0000000..6181b79 --- /dev/null +++ b/tools/pack_readme_zh.txt @@ -0,0 +1,20 @@ +包名 : {{PKG_NAME}} +项目 : {{PROJECT}} +版本 : {{VERSION}} +日期 : {{DATE}} + +文件说明: +{{FILE_LIST}} + +使用说明: +1. 批量烧录器:打开 *_burner.fw。 +2. 杰理 UFW 通道(部分 APP / 小程序):上传 *_app_ota.ufw。 +3. 走本协议 55AA 的服务器 OTA(APP / 小程序 / 网关都一样):上传 *_gateway_ota.bin。 + Type=0x02(BLE),不要传 ufw / fw / 普通 app.bin。 +4. 杰理网关若单独吃双备份包:同样用 *_gateway_ota.bin。 + +不带 Key(*_nokey_*):调试、未加密芯片。 +带 Key(*_key_*):加密镜像,烧录器 / 升级工具必须配置同一把 key(RS-5B88)。 + +本包不包含 .key 文件,请不要把工厂 key 发给终端用户。 +本机 USB:.\build.bat 默认烧 nokey;.\build.bat key 烧带 Key。两套文件都会打包。