diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..39912ed --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,1269 @@ +# Unfortunately, the current esp-open-rtos libs have several cross dependences. +# Libraries are separated into headers with exposed include paths and sources +# which utilize those paths. + +load("@//bazel:cc_static_library.bzl", "cc_static_library") +load("@//bazel:postprocess_static_library.bzl", "postprocess_static_library") + +the_kitchen_sink = [ + "-Wall", + "-nostdlib", + "-Iexternal/esp_open_rtos/lwip/lwip/src/include", + "-Iexternal/esp_open_rtos/lwip/lwip/src/include/lwip", + "-Iexternal/esp_open_rtos/lwip/include", + "-Iexternal/esp_open_rtos/open_esplibs/include", + "-Iexternal/esp_open_rtos/include", + "-Iexternal/esp_open_rtos/core/include", + "-Iexternal/esp_open_rtos/core", + "-Iexternal/esp_open_rtos/FreeRTOS/Source/include", + "-Iexternal/esp_open_rtos/FreeRTOS/Source/portable/esp8266", +] + +cc_library( + name = "core_headers", + hdrs = glob([ + "core/*.s", + "core/include/*.h", + "core/include/esp/*.h", + "include/*.h", + "include/espressif/*.h", + "include/espressif/esp8266/*.h", + ]), + visibility = ["//visibility:public"], +) + +cc_library( + name = "esplib_headers", + hdrs = glob([ + "open_esplibs/include/open_esplibs.h", + "open_esplibs/include/esplibs/*.h", + ]), + visibility = ["//visibility:public"], +) + +cc_library( + name = "freertos_headers", + hdrs = glob([ + "FreeRTOS/Source/include/*.h", + "FreeRTOS/Source/portable/esp8266/*.h", + ]), + visibility = ["//visibility:public"], +) + +cc_library( + name = "lwip_headers", + hdrs = glob([ + "lwip/lwip/src/include/*.h", + "lwip/include/*.h", + "lwip/include/arch/*.h", + "lwip/lwip/src/include/compat/posix/*.h", + "lwip/lwip/src/include/lwip/*.h", + "lwip/lwip/src/include/netif/*.h", + "lwip/lwip/src/include/netif/ppp/*.h", + "lwip/lwip/src/include/lwip/prot/*.h", + "lwip/lwip/src/include/lwip/priv/*.h", + ]), + visibility = ["//visibility:public"], +) + +cc_library( + name = "open_esplibs_libmain_asm", + srcs = [ + "open_esplibs/libmain/xtensa_context.S", + ], + copts = [ + "-mtext-section-literals", + "-mlongcalls", + "-Wl,-EL", + "-Iexternal/esp_open_rtos/open_esplibs/include", + ], + deps = [ + ":esplib_headers", + ], +) + +cc_library( + name = "open_esplibs_libmain", + srcs = glob([ + "open_esplibs/libmain/*.c", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ":open_esplibs_libmain_asm", + ], + alwayslink = True, +) + +cc_library( + name = "open_esplibs_libnet80211", + srcs = glob([ + "open_esplibs/libnet80211/*.c", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ], + alwayslink = True, +) + +cc_library( + name = "open_esplibs_libphy", + srcs = glob([ + "open_esplibs/libphy/*.c", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ], + alwayslink = True, +) + +cc_library( + name = "open_esplibs_libpp", + srcs = glob([ + "open_esplibs/libpp/*.c", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ], + alwayslink = True, +) + +cc_library( + name = "open_esplibs_libwpa", + srcs = glob([ + "open_esplibs/libwpa/*.c", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ], + alwayslink = True, +) + +cc_library( + name = "core_asm", + srcs = glob([ + "core/*.S", + ]), + hdrs = [ + "core/led_debug.s", + ], + copts = the_kitchen_sink + [ + "-mtext-section-literals", + "-mlongcalls", + ], +) + +cc_library( + name = "core", + srcs = glob([ + "core/*.c", + "core/*.cpp", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + defines = ["BAZEL_BUILD"], + visibility = ["//visibility:public"], + deps = [ + ":core_asm", + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ], +) + +cc_library( + name = "lwip", + srcs = glob([ + "lwip/lwip/src/api/*.c", + "lwip/lwip/src/core/*.c", + "lwip/lwip/src/core/ipv4/*.c", + "lwip/lwip/src/core/ipv6/*.c", + "lwip/lwip/src/netif/*.c", + "lwip/lwip/src/include/lwip/priv/*.h", + "lwip/lwip/src/include/lwip/prot/*.h", + "lwip/*.c", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ], +) + +cc_library( + name = "freertos", + srcs = glob([ + "FreeRTOS/Source/*.c", + "FreeRTOS/Source/portable/esp8266/*.c", + ]), + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":esplib_headers", + ":freertos_headers", + ":lwip_headers", + ], +) + +symbol_redefs = { + "aes_decrypt_deinit": "sdk_aes_decrypt_deinit", + "aes_decrypt_init": "sdk_aes_decrypt_init", + "aes_decrypt": "sdk_aes_decrypt", + "aes_encrypt_deinit": "sdk_aes_encrypt_deinit", + "aes_encrypt_init": "sdk_aes_encrypt_init", + "aes_encrypt": "sdk_aes_encrypt", + "aes_unwrap": "sdk_aes_unwrap", + "aes_wrap": "sdk_aes_wrap", + "ant_switch_init": "sdk_ant_switch_init", + "auth_type": "sdk_auth_type", + "bb_init": "sdk_bb_init", + "bbpll_cal_flag": "sdk_bbpll_cal_flag", + "bbpll_cal": "sdk_bbpll_cal", + "cal_rf_ana_gain": "sdk_cal_rf_ana_gain", + "cannel_scan_connect_state": "sdk_cannel_scan_connect_state", + "ccmp": "sdk_ccmp", + "change_bbpll160": "sdk_change_bbpll160", + "change_bbpll160_sleep": "sdk_change_bbpll160_sleep", + "check_data_flag": "sdk_check_data_flag", + "check_data_func": "sdk_check_data_func", + "check_result": "sdk_check_result", + "chip_60_set_channel": "sdk_chip_60_set_channel", + "chip6_phy_init_ctrl": "sdk_chip6_phy_init_ctrl", + "chip6_sleep_params": "sdk_chip6_sleep_params", + "chip_v6_get_sense": "sdk_chip_v6_get_sense", + "chip_v6_initialize_bb": "sdk_chip_v6_initialize_bb", + "chip_v6_rf_init": "sdk_chip_v6_rf_init", + "chip_v6_rxmax_ext_ana": "sdk_chip_v6_rxmax_ext_ana", + "chip_v6_rxmax_ext_dig": "sdk_chip_v6_rxmax_ext_dig", + "chip_v6_rxmax_ext": "sdk_chip_v6_rxmax_ext", + "chip_v6_set_chanfreq": "sdk_chip_v6_set_chanfreq", + "chip_v6_set_chan_misc": "sdk_chip_v6_set_chan_misc", + "chip_v6_set_chan_offset": "sdk_chip_v6_set_chan_offset", + "chip_v6_set_chan_rx_cmp": "sdk_chip_v6_set_chan_rx_cmp", + "chip_v6_set_chan": "sdk_chip_v6_set_chan", + "chip_v6_set_chan_wakeup": "sdk_chip_v6_set_chan_wakeup", + "chip_v6_set_sense": "sdk_chip_v6_set_sense", + "chip_v6_unset_chanfreq": "sdk_chip_v6_unset_chanfreq", + "chip_version": "sdk_chip_version", + "chm_acquire_lock": "sdk_chm_acquire_lock", + "chm_cancel_op": "sdk_chm_cancel_op", + "chm_check_same_channel": "sdk_chm_check_same_channel", + "chm_end_op": "sdk_chm_end_op", + "chm_freq2index": "sdk_chm_freq2index", + "chm_get_current_channel": "sdk_chm_get_current_channel", + "chm_init": "sdk_chm_init", + "chm_release_lock": "sdk_chm_release_lock", + "chm_return_home_channel": "sdk_chm_return_home_channel", + "chm_set_current_channel": "sdk_chm_set_current_channel", + "chm_start_op": "sdk_chm_start_op", + "clockgate_watchdog": "sdk_clockgate_watchdog", + "cnx_add_rc": "sdk_cnx_add_rc", + "cnx_attach": "sdk_cnx_attach", + "cnx_bss_alloc": "sdk_cnx_bss_alloc", + "cnx_connect_timeout": "sdk_cnx_connect_timeout", + "cnx_node_alloc": "sdk_cnx_node_alloc", + "cnx_node_join": "sdk_cnx_node_join", + "cnx_node_leave": "sdk_cnx_node_leave", + "cnx_node_remove": "sdk_cnx_node_remove", + "cnx_node_search": "sdk_cnx_node_search", + "cnx_rc_search": "sdk_cnx_rc_search", + "cnx_rc_update_age": "sdk_cnx_rc_update_age", + "cnx_rc_update_rssi": "sdk_cnx_rc_update_rssi", + "cnx_rc_update_state_metric": "sdk_cnx_rc_update_state_metric", + "cnx_remove_rc": "sdk_cnx_remove_rc", + "cnx_sta_associated": "sdk_cnx_sta_associated", + "cnx_sta_connect_cmd": "sdk_cnx_sta_connect_cmd", + "cnx_sta_connect_led_timer_cb": "sdk_cnx_sta_connect_led_timer_cb", + "cnx_sta_leave": "sdk_cnx_sta_leave", + "cnx_start_handoff_cb": "sdk_cnx_start_handoff_cb", + "cnx_sta_scan_cmd": "sdk_cnx_sta_scan_cmd", + "cnx_update_bss_more": "sdk_cnx_update_bss_more", + "cnx_update_bss": "sdk_cnx_update_bss", + "correct_rf_ana_gain": "sdk_correct_rf_ana_gain", + "cpu_overclock": "sdk_cpu_overclock", + "data_collect": "sdk_data_collect", + "dbg_stop_hw_wdt": "sdk_dbg_stop_hw_wdt", + "dbg_stop_sw_wdt": "sdk_dbg_stop_sw_wdt", + "dcoindex2txbbgain": "sdk_dcoindex2txbbgain", + "debug_timerfn": "sdk_debug_timerfn", + "debug_timer": "sdk_debug_timer", + "deep_sleep_en": "sdk_deep_sleep_en", + "dhcp_bind_check": "sdk_dhcp_bind_check", + "dhcpc_flag": "sdk_dhcpc_flag", + "do_noisefloor_lsleep_v50": "sdk_do_noisefloor_lsleep_v50", + "do_noisefloor": "sdk_do_noisefloor", + "do_pwctrl_flag": "sdk_do_pwctrl_flag", + "dpd_db2linear": "sdk_dpd_db2linear", + "dpd_index": "sdk_dpd_index", + "dpd_init": "sdk_dpd_init", + "dpd_mem_write": "sdk_dpd_mem_write", + "dpd_scale_set": "sdk_dpd_scale_set", + "eagle_auth_done": "sdk_eagle_auth_done", + "eapol_txcb": "sdk_eapol_txcb", + "eloop_cancel_timeout": "sdk_eloop_cancel_timeout", + "eloop_register_timeout": "sdk_eloop_register_timeout", + "esf_buf_alloc": "sdk_esf_buf_alloc", + "esf_buf_recycle": "sdk_esf_buf_recycle", + "esf_buf_setup": "sdk_esf_buf_setup", + "esf_rx_buf_alloc": "sdk_esf_rx_buf_alloc", + "ets_delay_us": "sdk_ets_delay_us", + "ets_timer_arm_ms_us": "sdk_ets_timer_arm_ms_us", + "ets_timer_arm": "sdk_ets_timer_arm", + "ets_timer_arm_us": "sdk_ets_timer_arm_us", + "ets_timer_disarm": "sdk_ets_timer_disarm", + "ets_timer_done": "sdk_ets_timer_done", + "ets_timer_handler_isr": "sdk_ets_timer_handler_isr", + "ets_timer_init": "sdk_ets_timer_init", + "ets_timer_setfn": "sdk_ets_timer_setfn", + "ets_update_cpu_frequency": "sdk_ets_update_cpu_frequency", + "flashchip": "sdk_flashchip", + "g_cnx_probe_rc_list_cb": "sdk_g_cnx_probe_rc_list_cb", + "gen_rx_gain_table": "sdk_gen_rx_gain_table", + "GetAccess": "sdk_GetAccess", + "get_check_flag": "sdk_get_check_flag", + "get_chip_version": "sdk_get_chip_version", + "get_fcc_1m2m_pwr_offset": "sdk_get_fcc_1m2m_pwr_offset", + "get_noisefloor_sat": "sdk_get_noisefloor_sat", + "get_pwctrl_correct": "sdk_get_pwctrl_correct", + "get_rf_gain_qdb": "sdk_get_rf_gain_qdb", + "get_sar_dout": "sdk_get_sar_dout", + "get_target_power_offset": "sdk_get_target_power_offset", + "g_ic": "sdk_g_ic", + "g_phyFuns_instance": "sdk_g_phyFuns_instance", + "g_phyFuns": "sdk_g_phyFuns", + "gpio_output_set": "sdk_gpio_output_set", + "gScanStruct": "sdk_gScanStruct", + "hardware_reject": "sdk_hardware_reject", + "hex2byte": "sdk_hex2byte", + "hexstr2bin": "sdk_hexstr2bin", + "hmac_md5": "sdk_hmac_md5", + "hmac_md5_vector": "sdk_hmac_md5_vector", + "hmac_sha1": "sdk_hmac_sha1", + "hmac_sha1_vector": "sdk_hmac_sha1_vector", + "hostapd_config_defaults_bss": "sdk_hostapd_config_defaults_bss", + "hostapd_config_defaults": "sdk_hostapd_config_defaults", + "hostapd_get_psk": "sdk_hostapd_get_psk", + "hostapd_mac_comp_empty": "sdk_hostapd_mac_comp_empty", + "hostapd_mac_comp": "sdk_hostapd_mac_comp", + "hostapd_maclist_found": "sdk_hostapd_maclist_found", + "hostapd_rate_found": "sdk_hostapd_rate_found", + "hostapd_setup_wpa_psk": "sdk_hostapd_setup_wpa_psk", + "hostapd_wep_key_cmp": "sdk_hostapd_wep_key_cmp", + "hostap_handle_timer": "sdk_hostap_handle_timer", + "hostap_input": "sdk_hostap_input", + "ic_bss_info_update": "sdk_ic_bss_info_update", + "ic_disable_interface": "sdk_ic_disable_interface", + "ic_enable_interface": "sdk_ic_enable_interface", + "ic_get_addr": "sdk_ic_get_addr", + "ic_get_gtk_alg": "sdk_ic_get_gtk_alg", + "ic_get_ptk_alg": "sdk_ic_get_ptk_alg", + "ic_interface_enabled": "sdk_ic_interface_enabled", + "ic_interface_is_p2p": "sdk_ic_interface_is_p2p", + "ic_is_pure_sta": "sdk_ic_is_pure_sta", + "ic_remove_key": "sdk_ic_remove_key", + "ic_set_gtk_alg": "sdk_ic_set_gtk_alg", + "ic_set_key": "sdk_ic_set_key", + "ic_set_opmode": "sdk_ic_set_opmode", + "ic_set_ptk_alg": "sdk_ic_set_ptk_alg", + "ic_set_sta": "sdk_ic_set_sta", + "ic_set_vif": "sdk_ic_set_vif", + "ieee80211_addbasicrates": "sdk_ieee80211_addbasicrates", + "ieee80211_add_htcap": "sdk_ieee80211_add_htcap", + "ieee80211_add_htcap_vendor": "sdk_ieee80211_add_htcap_vendor", + "ieee80211_add_htinfo": "sdk_ieee80211_add_htinfo", + "ieee80211_add_htinfo_vendor": "sdk_ieee80211_add_htinfo_vendor", + "ieee80211_add_rates": "sdk_ieee80211_add_rates", + "ieee80211_addr_bcast": "sdk_ieee80211_addr_bcast", + "ieee80211_add_xrates": "sdk_ieee80211_add_xrates", + "ieee80211_alloc_challenge": "sdk_ieee80211_alloc_challenge", + "ieee80211_alloc_proberesp": "sdk_ieee80211_alloc_proberesp", + "ieee80211_beacon_alloc": "sdk_ieee80211_beacon_alloc", + "ieee80211_chan2ieee": "sdk_ieee80211_chan2ieee", + "ieee80211_compute_duration": "sdk_ieee80211_compute_duration", + "ieee80211_crypto_attach": "sdk_ieee80211_crypto_attach", + "ieee80211_crypto_available": "sdk_ieee80211_crypto_available", + "ieee80211_crypto_decap": "sdk_ieee80211_crypto_decap", + "ieee80211_crypto_encap": "sdk_ieee80211_crypto_encap", + "ieee80211_crypto_setkey": "sdk_ieee80211_crypto_setkey", + "ieee80211_decap": "sdk_ieee80211_decap", + "ieee80211_deliver_data": "sdk_ieee80211_deliver_data", + "ieee80211_dot11Rate_rix": "sdk_ieee80211_dot11Rate_rix", + "ieee80211_find_channel_byieee": "sdk_ieee80211_find_channel_byieee", + "ieee80211_find_channel": "sdk_ieee80211_find_channel", + "ieee80211_get_11g_ratetable": "sdk_ieee80211_get_11g_ratetable", + "ieee80211_getcapinfo": "sdk_ieee80211_getcapinfo", + "ieee80211_getmgtframe": "sdk_ieee80211_getmgtframe", + "ieee80211_get_ratetable": "sdk_ieee80211_get_ratetable", + "ieee80211_hostap_attach": "sdk_ieee80211_hostap_attach", + "ieee80211_ht_attach": "sdk_ieee80211_ht_attach", + "ieee80211_ht_node_cleanup": "sdk_ieee80211_ht_node_cleanup", + "ieee80211_ht_node_init": "sdk_ieee80211_ht_node_init", + "ieee80211_ht_updateparams": "sdk_ieee80211_ht_updateparams", + "ieee80211_ieee2mhz": "sdk_ieee80211_ieee2mhz", + "ieee80211_ifattach": "sdk_ieee80211_ifattach", + "ieee80211_iserp_rateset": "sdk_ieee80211_iserp_rateset", + "ieee80211_mgmt_output": "sdk_ieee80211_mgmt_output", + "ieee80211_mhz2ieee": "sdk_ieee80211_mhz2ieee", + "ieee80211_mlme_connect_bss": "sdk_ieee80211_mlme_connect_bss", + "ieee80211_node_pwrsave": "sdk_ieee80211_node_pwrsave", + "ieee80211_opcap": "sdk_ieee80211_opcap", + "ieee80211_output_pbuf": "sdk_ieee80211_output_pbuf", + "ieee80211_parse_action": "sdk_ieee80211_parse_action", + "ieee80211_parse_beacon": "sdk_ieee80211_parse_beacon", + "ieee80211_parse_htcap": "sdk_ieee80211_parse_htcap", + "ieee80211_parse_rsn": "sdk_ieee80211_parse_rsn", + "ieee80211_parse_wmeparams": "sdk_ieee80211_parse_wmeparams", + "ieee80211_parse_wpa": "sdk_ieee80211_parse_wpa", + "ieee80211_phy_init": "sdk_ieee80211_phy_init", + "ieee80211_phy_type_get": "sdk_ieee80211_phy_type_get", + "ieee80211_proto_attach": "sdk_ieee80211_proto_attach", + "ieee80211_psq_cleanup": "sdk_ieee80211_psq_cleanup", + "ieee80211_psq_init": "sdk_ieee80211_psq_init", + "ieee80211_pwrsave": "sdk_ieee80211_pwrsave", + "ieee80211_recv_action_register": "sdk_ieee80211_recv_action_register", + "ieee80211_recv_action": "sdk_ieee80211_recv_action", + "ieee80211_recv_action_unregister": "sdk_ieee80211_recv_action_unregister", + "ieee80211_scan_attach": "sdk_ieee80211_scan_attach", + "ieee80211_send_action_register": "sdk_ieee80211_send_action_register", + "ieee80211_send_action": "sdk_ieee80211_send_action", + "ieee80211_send_action_unregister": "sdk_ieee80211_send_action_unregister", + "ieee80211_send_mgmt": "sdk_ieee80211_send_mgmt", + "ieee80211_send_nulldata": "sdk_ieee80211_send_nulldata", + "ieee80211_send_probereq": "sdk_ieee80211_send_probereq", + "ieee80211_send_proberesp": "sdk_ieee80211_send_proberesp", + "ieee80211_send_setup": "sdk_ieee80211_send_setup", + "ieee80211_setbasicrates": "sdk_ieee80211_setbasicrates", + "ieee80211_set_shortslottime": "sdk_ieee80211_set_shortslottime", + "ieee80211_set_tim": "sdk_ieee80211_set_tim", + "ieee80211_setup_basic_htrates": "sdk_ieee80211_setup_basic_htrates", + "ieee80211_setup_htrates": "sdk_ieee80211_setup_htrates", + "ieee80211_setup_rateset": "sdk_ieee80211_setup_rateset", + "ieee80211_setup_rates": "sdk_ieee80211_setup_rates", + "ieee80211_setup_ratetable": "sdk_ieee80211_setup_ratetable", + "ieee80211_sta_new_state": "sdk_ieee80211_sta_new_state", + "ieee80211_tx_mgt_cb": "sdk_ieee80211_tx_mgt_cb", + "ieee80211_wme_initparams": "sdk_ieee80211_wme_initparams", + "ieee80211_wme_updateparams": "sdk_ieee80211_wme_updateparams", + "ieee802_1x_receive": "sdk_ieee802_1x_receive", + "if_ctrl": "sdk_if_ctrl", + "inc_byte_array": "sdk_inc_byte_array", + "info": "sdk_info", + "init_cal_dcoffset": "sdk_init_cal_dcoffset", + "interface_mask": "sdk_interface_mask", + "lmacConfMib": "sdk_lmacConfMib", + "lmacDiscardAgedMSDU": "sdk_lmacDiscardAgedMSDU", + "lmacInitAc": "sdk_lmacInitAc", + "lmacInit": "sdk_lmacInit", + "lmacIsActive": "sdk_lmacIsActive", + "lmacIsIdle": "sdk_lmacIsIdle", + "lmacMSDUAged": "sdk_lmacMSDUAged", + "lmacProcessAckTimeout": "sdk_lmacProcessAckTimeout", + "lmacProcessCollision": "sdk_lmacProcessCollision", + "lmacProcessCollisions": "sdk_lmacProcessCollisions", + "lmacProcessCtsTimeout": "sdk_lmacProcessCtsTimeout", + "lmacProcessRtsStart": "sdk_lmacProcessRtsStart", + "lmacProcessTxError": "sdk_lmacProcessTxError", + "lmacProcessTxRtsError": "sdk_lmacProcessTxRtsError", + "lmacProcessTXStartData": "sdk_lmacProcessTXStartData", + "lmacProcessTxSuccess": "sdk_lmacProcessTxSuccess", + "lmacRecycleMPDU": "sdk_lmacRecycleMPDU", + "lmacRxDone": "sdk_lmacRxDone", + "lmacSetAcParam": "sdk_lmacSetAcParam", + "lmacTxFrame": "sdk_lmacTxFrame", + "loop_pwctrl_correct_atten_high_power": "sdk_loop_pwctrl_correct_atten_high_power", + "loop_pwctrl_pwdet_error_accum_high_power": "sdk_loop_pwctrl_pwdet_error_accum_high_power", + "low_power_set": "sdk_low_power_set", + "MacIsrSigPostDefHdl": "sdk_MacIsrSigPostDefHdl", + "MD5Final": "sdk_MD5Final", + "MD5Init": "sdk_MD5Init", + "MD5Update": "sdk_MD5Update", + "md5_vector": "sdk_md5_vector", + "meas_tone_pwr_db": "sdk_meas_tone_pwr_db", + "NMIIrqIsOn": "sdk_NMIIrqIsOn", + "noise_array": "sdk_noise_array", + "noise_check_loop": "sdk_noise_check_loop", + "noise_init": "sdk_noise_init", + "NoiseTimerInterval": "sdk_NoiseTimerInterval", + "operation_test": "sdk_operation_test", + "os_delay_us": "sdk_os_delay_us", + "os_get_cpu_frequency": "sdk_os_get_cpu_frequency", + "os_get_random": "sdk_os_get_random", + "os_get_time": "sdk_os_get_time", + "os_install_putc1": "sdk_os_install_putc1", + "os_putc": "sdk_os_putc", + "os_random": "sdk_os_random", + "os_timer_arm": "sdk_os_timer_arm", + "os_timer_disarm": "sdk_os_timer_disarm", + "os_timer_setfn": "sdk_os_timer_setfn", + "os_update_cpu_frequency": "sdk_os_update_cpu_frequency", + "pbkdf2_sha1": "sdk_pbkdf2_sha1", + "pbuf_alloc": "sdk_pbuf_alloc", + "pbus_set_rxbbgain": "sdk_pbus_set_rxbbgain", + "pend_flag_noise_check": "sdk_pend_flag_noise_check", + "pend_flag_periodic_cal": "sdk_pend_flag_periodic_cal", + "PendFreeBcnEb": "sdk_PendFreeBcnEb", + "periodic_cal_dc_num": "sdk_periodic_cal_dc_num", + "periodic_cal_flag": "sdk_periodic_cal_flag", + "periodic_cal_sat": "sdk_periodic_cal_sat", + "periodic_cal": "sdk_periodic_cal", + "periodic_cal_top": "sdk_periodic_cal_top", + "phy_bb_rx_cfg": "sdk_phy_bb_rx_cfg", + "phy_change_channel": "sdk_phy_change_channel", + "phy_delete_channel": "sdk_phy_delete_channel", + "phy_dig_spur_prot": "sdk_phy_dig_spur_prot", + "phy_dig_spur_set": "sdk_phy_dig_spur_set", + "phy_disable_agc": "sdk_phy_disable_agc", + "phy_enable_agc": "sdk_phy_enable_agc", + "phy_freq_offset": "sdk_phy_freq_offset", + "phy_get_mactime": "sdk_phy_get_mactime", + "phy_get_romfuncs": "sdk_phy_get_romfuncs", + "phy_gpio_cfg": "sdk_phy_gpio_cfg", + "phy_initialize_bb": "sdk_phy_initialize_bb", + "phy_init": "sdk_phy_init", + "phy_pbus_soc_cfg": "sdk_phy_pbus_soc_cfg", + "phy_set_sense": "sdk_phy_set_sense", + "pm_allow_tx": "sdk_pm_allow_tx", + "pm_assoc_parse": "sdk_pm_assoc_parse", + "pm_attach": "sdk_pm_attach", + "pm_check_mac_idle": "sdk_pm_check_mac_idle", + "pm_enable_gpio_wakeup": "sdk_pm_enable_gpio_wakeup", + "pm_force_scan_unlock": "sdk_pm_force_scan_unlock", + "pm_get_idle_wait_time": "sdk_pm_get_idle_wait_time", + "pm_get_sleep_type": "sdk_pm_get_sleep_type", + "pm_goto_sleep": "sdk_pm_goto_sleep", + "pm_idle_sleep": "sdk_pm_idle_sleep", + "pm_is_open": "sdk_pm_is_open", + "pm_is_waked": "sdk_pm_is_waked", + "pm_onBcnRx": "sdk_pm_onBcnRx", + "pm_open_rf": "sdk_pm_open_rf", + "pm_open": "sdk_pm_open", + "pm_post": "sdk_pm_post", + "pm_prepare_to_sleep": "sdk_pm_prepare_to_sleep", + "pm_reset_idle_sleep": "sdk_pm_reset_idle_sleep", + "pm_rf_is_closed": "sdk_pm_rf_is_closed", + "pm_rtc2usec": "sdk_pm_rtc2usec", + "pm_rtc_clock_cali_proc": "sdk_pm_rtc_clock_cali_proc", + "pm_rtc_clock_cali": "sdk_pm_rtc_clock_cali", + "pm_scan_lock": "sdk_pm_scan_lock", + "pm_scan_unlocked": "sdk_pm_scan_unlocked", + "pm_sdio_nidle": "sdk_pm_sdio_nidle", + "pm_send_nullfunc": "sdk_pm_send_nullfunc", + "pm_set_addr": "sdk_pm_set_addr", + "pm_set_pll_xtal_wait_time": "sdk_pm_set_pll_xtal_wait_time", + "pm_set_sleep_btco": "sdk_pm_set_sleep_btco", + "pm_set_sleep_cycles": "sdk_pm_set_sleep_cycles", + "pm_set_sleep_mode": "sdk_pm_set_sleep_mode", + "pm_set_sleep_time": "sdk_pm_set_sleep_time", + "pm_set_sleep_type_from_upper": "sdk_pm_set_sleep_type_from_upper", + "pm_set_wakeup_btco": "sdk_pm_set_wakeup_btco", + "pm_set_wakeup_mac": "sdk_pm_set_wakeup_mac", + "pm_shutdown": "sdk_pm_shutdown", + "pm_sleep_for": "sdk_pm_sleep_for", + "pm_sleep_opt_bb_off": "sdk_pm_sleep_opt_bb_off", + "pm_sleep_opt_bb_on": "sdk_pm_sleep_opt_bb_on", + "pm_sleep_opt": "sdk_pm_sleep_opt", + "pm_sleep_set_mac": "sdk_pm_sleep_set_mac", + "pm_suspend": "sdk_pm_suspend", + "pm_try_scan_unlock": "sdk_pm_try_scan_unlock", + "pm_unmask_bt": "sdk_pm_unmask_bt", + "pm_usec2rtc": "sdk_pm_usec2rtc", + "pm_wait4wakeup": "sdk_pm_wait4wakeup", + "pm_wakeup_init": "sdk_pm_wakeup_init", + "pm_wakeup_opt": "sdk_pm_wakeup_opt", + "pp_attach": "sdk_pp_attach", + "ppCalFrameTimes": "sdk_ppCalFrameTimes", + "ppCalTxop": "sdk_ppCalTxop", + "ppCheckTxIdle": "sdk_ppCheckTxIdle", + "ppDequeueTxQ": "sdk_ppDequeueTxQ", + "pp_disable_idle_timer": "sdk_pp_disable_idle_timer", + "pp_disable_noise_timer": "sdk_pp_disable_noise_timer", + "ppDiscardMPDU": "sdk_ppDiscardMPDU", + "pp_enable_idle_timer": "sdk_pp_enable_idle_timer", + "pp_enable_noise_timer": "sdk_pp_enable_noise_timer", + "ppEnqueueRxq": "sdk_ppEnqueueRxq", + "ppEnqueueTxDone": "sdk_ppEnqueueTxDone", + "ppFetchTxQFirstAvail": "sdk_ppFetchTxQFirstAvail", + "ppGetTxQFirstAvail_Locked": "sdk_ppGetTxQFirstAvail_Locked", + "ppInstallKey": "sdk_ppInstallKey", + "pp_michael_mic_failure": "sdk_pp_michael_mic_failure", + "pp_noise_test": "sdk_pp_noise_test", + "ppPeocessRxPktHdr": "sdk_ppPeocessRxPktHdr", + "pp_post": "sdk_pp_post", + "ppProcessTxQ": "sdk_ppProcessTxQ", + "ppProcessWaitQ": "sdk_ppProcessWaitQ", + "ppRecordBarRRC": "sdk_ppRecordBarRRC", + "ppRecycleRxPkt": "sdk_ppRecycleRxPkt", + "ppRegisterTxCallback": "sdk_ppRegisterTxCallback", + "ppRollBackTxQ": "sdk_ppRollBackTxQ", + "pp_soft_wdt_feed": "sdk_pp_soft_wdt_feed", + "pp_soft_wdt_init": "sdk_pp_soft_wdt_init", + "ppTask": "sdk_ppTask", + "pp_try_enable_idle_timer": "sdk_pp_try_enable_idle_timer", + "ppTxPkt": "sdk_ppTxPkt", + "ppTxqUpdateBitmap": "sdk_ppTxqUpdateBitmap", + "PPWdtReset": "sdk_PPWdtReset", + "promiscuous_cb": "sdk_promiscuous_cb", + "_putc1": "sdk__putc1", + "pwctrl_debug": "sdk_pwctrl_debug", + "ram_cal_tos_v60": "sdk_ram_cal_tos_v60", + "ram_chip_v6_rx_init": "sdk_ram_chip_v6_rx_init", + "ram_get_bb_atten": "sdk_ram_get_bb_atten", + "ram_get_corr_power": "sdk_ram_get_corr_power", + "ram_get_fm_sar_dout": "sdk_ram_get_fm_sar_dout", + "ram_get_noisefloor": "sdk_ram_get_noisefloor", + "ram_pbus_debugmode": "sdk_ram_pbus_debugmode", + "ram_pbus_set_rxgain": "sdk_ram_pbus_set_rxgain", + "ram_pbus_xpd_tx_on": "sdk_ram_pbus_xpd_tx_on", + "ram_restart_cal": "sdk_ram_restart_cal", + "ram_rfcal_pwrctrl": "sdk_ram_rfcal_pwrctrl", + "ram_rfcal_rxiq": "sdk_ram_rfcal_rxiq", + "ram_rfcal_txcap": "sdk_ram_rfcal_txcap", + "ram_rfcal_txiq": "sdk_ram_rfcal_txiq", + "ram_rfpll_set_freq": "sdk_ram_rfpll_set_freq", + "ram_rxiq_cover_mg_mp": "sdk_ram_rxiq_cover_mg_mp", + "ram_rxiq_get_mis": "sdk_ram_rxiq_get_mis", + "ram_set_channel_freq": "sdk_ram_set_channel_freq", + "ram_set_noise_floor": "sdk_ram_set_noise_floor", + "ram_set_txbb_atten": "sdk_ram_set_txbb_atten", + "ram_start_noisefloor": "sdk_ram_start_noisefloor", + "ram_tx_mac_disable": "sdk_ram_tx_mac_disable", + "ram_tx_mac_enable": "sdk_ram_tx_mac_enable", + "rand": "hwrand", + "rc4_skip": "sdk_rc4_skip", + "rcAttach": "sdk_rcAttach", + "rc_cal": "sdk_rc_cal", + "rc_disable_trc_by_interface": "sdk_rc_disable_trc_by_interface", + "rc_disable_trc": "sdk_rc_disable_trc", + "rc_enable_trc": "sdk_rc_enable_trc", + "RC_GetAckRate": "sdk_RC_GetAckRate", + "RC_GetAckTime": "sdk_RC_GetAckTime", + "RC_GetBlockAckTime": "sdk_RC_GetBlockAckTime", + "RC_GetCtsTime": "sdk_RC_GetCtsTime", + "rc_get_mask": "sdk_rc_get_mask", + "rcGetRate": "sdk_rcGetRate", + "RC_GetRtsRate": "sdk_RC_GetRtsRate", + "rcGetSched": "sdk_rcGetSched", + "rc_get_sta_trc": "sdk_rc_get_sta_trc", + "rc_get_trc_by_index": "sdk_rc_get_trc_by_index", + "rc_get_trc": "sdk_rc_get_trc", + "rcGetTrc": "sdk_rcGetTrc", + "rc_only_sta_trc": "sdk_rc_only_sta_trc", + "rcons": "sdk_rcons", + "rcReachRetryLimit": "sdk_rcReachRetryLimit", + "RC_SetBasicRate": "sdk_RC_SetBasicRate", + "rcUpdateDataRxDone": "sdk_rcUpdateDataRxDone", + "rcUpdatePhyMode": "sdk_rcUpdatePhyMode", + "rcUpdateRxDone": "sdk_rcUpdateRxDone", + "rcUpdateTxDone": "sdk_rcUpdateTxDone", + "read_hw_noisefloor": "sdk_read_hw_noisefloor", + "read_sar_dout": "sdk_read_sar_dout", + "readvdd33": "sdk_readvdd33", + "register_chipv6_phy_init_param": "sdk_register_chipv6_phy_init_param", + "register_chipv6_phy": "sdk_register_chipv6_phy", + "register_phy_ops": "sdk_register_phy_ops", + "reset_noise_timer": "sdk_reset_noise_timer", + "RFChannelSel": "sdk_RFChannelSel", + "rf_init": "sdk_rf_init", + "rijndaelEncrypt": "sdk_rijndaelEncrypt", + "rijndaelKeySetupDec": "sdk_rijndaelKeySetupDec", + "rijndaelKeySetupEnc": "sdk_rijndaelKeySetupEnc", + "rom_abs_temp": "sdk_rom_abs_temp", + "rom_ana_inf_gating_en": "sdk_rom_ana_inf_gating_en", + "rom_cal_tos_v50": "sdk_rom_cal_tos_v50", + "rom_chip_50_set_channel": "sdk_rom_chip_50_set_channel", + "rom_chip_v5_disable_cca": "sdk_rom_chip_v5_disable_cca", + "rom_chip_v5_enable_cca": "sdk_rom_chip_v5_enable_cca", + "rom_chip_v5_rx_init": "sdk_rom_chip_v5_rx_init", + "rom_chip_v5_sense_backoff": "sdk_rom_chip_v5_sense_backoff", + "rom_chip_v5_tx_init": "sdk_rom_chip_v5_tx_init", + "rom_dc_iq_est": "sdk_rom_dc_iq_est", + "rom_en_pwdet": "sdk_rom_en_pwdet", + "rom_get_bb_atten": "sdk_rom_get_bb_atten", + "rom_get_corr_power": "sdk_rom_get_corr_power", + "rom_get_fm_sar_dout": "sdk_rom_get_fm_sar_dout", + "rom_get_noisefloor": "sdk_rom_get_noisefloor", + "rom_get_power_db": "sdk_rom_get_power_db", + "rom_i2c_readReg_Mask": "sdk_rom_i2c_readReg_Mask", + "rom_i2c_readReg": "sdk_rom_i2c_readReg", + "rom_i2c_writeReg_Mask": "sdk_rom_i2c_writeReg_Mask", + "rom_i2c_writeReg": "sdk_rom_i2c_writeReg", + "rom_iq_est_disable": "sdk_rom_iq_est_disable", + "rom_iq_est_enable": "sdk_rom_iq_est_enable", + "rom_linear_to_db": "sdk_rom_linear_to_db", + "rom_mhz2ieee": "sdk_rom_mhz2ieee", + "rom_pbus_dco___SA2": "sdk_rom_pbus_dco___SA2", + "rom_pbus_debugmode": "sdk_rom_pbus_debugmode", + "rom_pbus_enter_debugmode": "sdk_rom_pbus_enter_debugmode", + "rom_pbus_exit_debugmode": "sdk_rom_pbus_exit_debugmode", + "rom_pbus_force_test": "sdk_rom_pbus_force_test", + "rom_pbus_rd": "sdk_rom_pbus_rd", + "rom_pbus_set_rxgain": "sdk_rom_pbus_set_rxgain", + "rom_pbus_set_txgain": "sdk_rom_pbus_set_txgain", + "rom_pbus_workmode": "sdk_rom_pbus_workmode", + "rom_pbus_xpd_rx_off": "sdk_rom_pbus_xpd_rx_off", + "rom_pbus_xpd_rx_on": "sdk_rom_pbus_xpd_rx_on", + "rom_pbus_xpd_tx_off": "sdk_rom_pbus_xpd_tx_off", + "rom_pbus_xpd_tx_on__low_gain": "sdk_rom_pbus_xpd_tx_on__low_gain", + "rom_pbus_xpd_tx_on": "sdk_rom_pbus_xpd_tx_on", + "rom_phy_reset_req": "sdk_rom_phy_reset_req", + "rom_restart_cal": "sdk_rom_restart_cal", + "rom_rfcal_pwrctrl": "sdk_rom_rfcal_pwrctrl", + "rom_rfcal_rxiq": "sdk_rom_rfcal_rxiq", + "rom_rfcal_rxiq_set_reg": "sdk_rom_rfcal_rxiq_set_reg", + "rom_rfcal_txcap": "sdk_rom_rfcal_txcap", + "rom_rfcal_txiq_cover": "sdk_rom_rfcal_txiq_cover", + "rom_rfcal_txiq": "sdk_rom_rfcal_txiq", + "rom_rfcal_txiq_set_reg": "sdk_rom_rfcal_txiq_set_reg", + "rom_rfpll_reset": "sdk_rom_rfpll_reset", + "rom_rfpll_set_freq": "sdk_rom_rfpll_set_freq", + "rom_rxiq_cover_mg_mp": "sdk_rom_rxiq_cover_mg_mp", + "rom_rxiq_get_mis": "sdk_rom_rxiq_get_mis", + "rom_sar_init": "sdk_rom_sar_init", + "rom_set_ana_inf_tx_scale": "sdk_rom_set_ana_inf_tx_scale", + "rom_set_channel_freq": "sdk_rom_set_channel_freq", + "rom_set_loopback_gain": "sdk_rom_set_loopback_gain", + "rom_set_noise_floor": "sdk_rom_set_noise_floor", + "rom_set_rxclk_en": "sdk_rom_set_rxclk_en", + "rom_set_txbb_atten": "sdk_rom_set_txbb_atten", + "rom_set_txclk_en": "sdk_rom_set_txclk_en", + "rom_set_txiq_cal": "sdk_rom_set_txiq_cal", + "rom_start_noisefloor": "sdk_rom_start_noisefloor", + "rom_start_tx_tone": "sdk_rom_start_tx_tone", + "rom_stop_tx_tone": "sdk_rom_stop_tx_tone", + "rom_tx_mac_disable": "sdk_rom_tx_mac_disable", + "rom_tx_mac_enable": "sdk_rom_tx_mac_enable", + "rom_txtone_linear_pwr": "sdk_rom_txtone_linear_pwr", + "rom_write_rfpll_sdm": "sdk_rom_write_rfpll_sdm", + "rsn_cipher_put_suites": "sdk_rsn_cipher_put_suites", + "rsn_pmkid": "sdk_rsn_pmkid", + "rst_if": "sdk_rst_if", + "rtc_get_reset_reason": "sdk_rtc_get_reset_reason", + "rtc_mem_backup": "sdk_rtc_mem_backup", + "rtc_mem_recovery": "sdk_rtc_mem_recovery", + "rxdc_init_flag": "sdk_rxdc_init_flag", + "rx_gain_swp": "sdk_rx_gain_swp", + "rxiq_compute_num": "sdk_rxiq_compute_num", + "rxiq_cover_fail_num": "sdk_rxiq_cover_fail_num", + "RxNodeNum": "sdk_RxNodeNum", + "scan_add_bssid": "sdk_scan_add_bssid", + "scan_add_probe_ssid": "sdk_scan_add_probe_ssid", + "scan_cancel": "sdk_scan_cancel", + "scan_check_hidden": "sdk_scan_check_hidden", + "scan_clear_channles": "sdk_scan_clear_channles", + "scan_connect_state": "sdk_scan_connect_state", + "scan_get_type": "sdk_scan_get_type", + "scan_hidden_ssid": "sdk_scan_hidden_ssid", + "scannum": "sdk_scannum", + "scan_parse_beacon": "sdk_scan_parse_beacon", + "scan_pm_channel_op_cb": "sdk_scan_pm_channel_op_cb", + "scan_profile_check": "sdk_scan_profile_check", + "scan_remove_bssid": "sdk_scan_remove_bssid", + "scan_remove_probe_ssid": "sdk_scan_remove_probe_ssid", + "scan_set_desChan": "sdk_scan_set_desChan", + "scan_start": "sdk_scan_start", + "SDIO_slp_reject": "sdk_SDIO_slp_reject", + "sdt_on_noise_start": "sdk_sdt_on_noise_start", + "set_cal_rxdc": "sdk_set_cal_rxdc", + "set_crystal_uart": "sdk_set_crystal_uart", + "set_rfanagain_dc_reg": "sdk_set_rfanagain_dc_reg", + "set_rf_freq_offset": "sdk_set_rf_freq_offset", + "set_rx_gain_cal_iq": "sdk_set_rx_gain_cal_iq", + "set_rx_gain_testchip_50": "sdk_set_rx_gain_testchip_50", + "set_txcap_reg": "sdk_set_txcap_reg", + "set_txdc_pbus": "sdk_set_txdc_pbus", + "SHA1Final": "sdk_SHA1Final", + "SHA1Init": "sdk_SHA1Init", + "sha1_prf": "sdk_sha1_prf", + "SHA1Transform": "sdk_SHA1Transform", + "SHA1Update": "sdk_SHA1Update", + "sha1_vector": "sdk_sha1_vector", + "sleep_opt_8266": "sdk_sleep_opt_8266", + "sleep_opt_bb_on_8266": "sdk_sleep_opt_bb_on_8266", + "sleep_reset_analog_rtcreg_8266": "sdk_sleep_reset_analog_rtcreg_8266", + "sleep_start_wait_time": "sdk_sleep_start_wait_time", + "slop_test": "sdk_slop_test", + "slop_wdt_feed": "sdk_slop_wdt_feed", + "software_slp_reject": "sdk_software_slp_reject", + "SPIEraseSector": "sdk_SPIEraseSector", + "spi_flash_erase_sector": "sdk_spi_flash_erase_sector", + "spi_flash_get_id": "sdk_spi_flash_get_id", + "spi_flash_read": "sdk_spi_flash_read", + "spi_flash_read_status": "sdk_spi_flash_read_status", + "spi_flash_write": "sdk_spi_flash_write", + "spi_flash_write_status": "sdk_spi_flash_write_status", + "SPIReadModeCnfig": "sdk_SPIReadModeCnfig", + "SPIRead": "sdk_SPIRead", + "SPIWrite": "sdk_SPIWrite", + "sta_con_timer": "sdk_sta_con_timer", + "sta_input": "sdk_sta_input", + "start_dig_rx": "sdk_start_dig_rx", + "sta_status_set": "sdk_sta_status_set", + "stop_dig_rx": "sdk_stop_dig_rx", + "sw_scan_mode": "sdk_sw_scan_mode", + "system_adc_read": "sdk_system_adc_read", + "system_deep_sleep": "sdk_system_deep_sleep", + "system_get_boot_mode": "sdk_system_get_boot_mode", + "system_get_boot_version": "sdk_system_get_boot_version", + "system_get_checksum": "sdk_system_get_checksum", + "system_get_chip_id": "sdk_system_get_chip_id", + "system_get_cpu_freq": "sdk_system_get_cpu_freq", + "system_get_free_heap_size": "sdk_system_get_free_heap_size", + "system_get_rst_info": "sdk_system_get_rst_info", + "system_get_rtc_time": "sdk_system_get_rtc_time", + "system_get_sdk_version": "sdk_system_get_sdk_version", + "system_get_test_result": "sdk_system_get_test_result", + "system_get_time": "sdk_system_get_time", + "system_get_userbin_addr": "sdk_system_get_userbin_addr", + "system_overclock": "sdk_system_overclock", + "system_pp_recycle_rx_pkt": "sdk_system_pp_recycle_rx_pkt", + "system_print_meminfo": "sdk_system_print_meminfo", + "system_relative_time": "sdk_system_relative_time", + "system_restart_enhance": "sdk_system_restart_enhance", + "system_restart_in_nmi": "sdk_system_restart_in_nmi", + "system_restart": "sdk_system_restart", + "system_restoreclock": "sdk_system_restoreclock", + "system_restore": "sdk_system_restore", + "system_rtc_clock_cali_proc": "sdk_system_rtc_clock_cali_proc", + "system_rtc_mem_read": "sdk_system_rtc_mem_read", + "system_rtc_mem_write": "sdk_system_rtc_mem_write", + "system_station_got_ip_set": "sdk_system_station_got_ip_set", + "system_uart_swap": "sdk_system_uart_swap", + "system_update_cpu_freq": "sdk_system_update_cpu_freq", + "system_upgrade_flag_check": "sdk_system_upgrade_flag_check", + "system_upgrade_flag_set": "sdk_system_upgrade_flag_set", + "system_upgrade_reboot": "sdk_system_upgrade_reboot", + "system_upgrade_userbin_check": "sdk_system_upgrade_userbin_check", + "system_upgrade_userbin_set": "sdk_system_upgrade_userbin_set", + "target_power_add_backoff": "sdk_target_power_add_backoff", + "target_power_backoff": "sdk_target_power_backoff", + "Td0": "sdk_Td0", + "Td4s_rom": "sdk_Td4s_rom", + "Te0": "sdk_Te0", + "test_rffreq_txcap": "sdk_test_rffreq_txcap", + "test_tout": "sdk_test_tout", + "tkip": "sdk_tkip", + "TmpSTAAPCloseAP": "sdk_TmpSTAAPCloseAP", + "trc_NeedRTS": "sdk_trc_NeedRTS", + "trc_onDisconnect": "sdk_trc_onDisconnect", + "trc_onScanDone": "sdk_trc_onScanDone", + "trc_onScanStart": "sdk_trc_onScanStart", + "tsen_meas": "sdk_tsen_meas", + "tx_atten_set_interp": "sdk_tx_atten_set_interp", + "txbbgain2dcoindex": "sdk_txbbgain2dcoindex", + "txbk_dpdby_flag": "sdk_txbk_dpdby_flag", + "tx_cap_init": "sdk_tx_cap_init", + "tx_cont_cfg": "sdk_tx_cont_cfg", + "tx_cont_dis": "sdk_tx_cont_dis", + "tx_cont_en": "sdk_tx_cont_en", + "Tx_Copy2Queue": "sdk_Tx_Copy2Queue", + "txiq_cover": "sdk_txiq_cover", + "txiq_get_mis_pwr": "sdk_txiq_get_mis_pwr", + "TxNodeNum": "sdk_TxNodeNum", + "tx_pwctrl_atten_init_en": "sdk_tx_pwctrl_atten_init_en", + "tx_pwctrl_atten_init": "sdk_tx_pwctrl_atten_init", + "tx_pwctrl_background": "sdk_tx_pwctrl_background", + "tx_pwctrl_bg_init": "sdk_tx_pwctrl_bg_init", + "tx_pwctrl_cal": "sdk_tx_pwctrl_cal", + "tx_pwctrl_init_cal": "sdk_tx_pwctrl_init_cal", + "tx_pwctrl_init": "sdk_tx_pwctrl_init", + "tx_pwctrl_pk_num": "sdk_tx_pwctrl_pk_num", + "tx_pwctrl_set_chan_flag": "sdk_tx_pwctrl_set_chan_flag", + "tx_pwr_backoff": "sdk_tx_pwr_backoff", + "txpwr_offset": "sdk_txpwr_offset", + "tx_rf_ana_gain": "sdk_tx_rf_ana_gain", + "uart_buff_switch": "sdk_uart_buff_switch", + "uart_div_modify": "sdk_uart_div_modify", + "Uart_Init": "sdk_Uart_Init", + "uart_rx_one_char": "sdk_uart_rx_one_char", + "uart_tx_flush": "sdk_uart_tx_flush", + "uart_wait_idle": "sdk_uart_wait_idle", + "user_fatal_exception_handler": "sdk_user_fatal_exception_handler", + "user_init_flag": "sdk_user_init_flag", + "user_init_task": "sdk_user_init_task", + "user_start": "sdk_user_start", + "wait_rfpll_cal_end": "sdk_wait_rfpll_cal_end", + "wDev_AppendRxAmpduLensBlocks": "sdk_wDev_AppendRxAmpduLensBlocks", + "wDev_AppendRxBlocks": "sdk_wDev_AppendRxBlocks", + "wDev_ClearBssid": "sdk_wDev_ClearBssid", + "wDev_ClearTxqCollisions": "sdk_wDev_ClearTxqCollisions", + "wDev_ClearWaitingQueue": "sdk_wDev_ClearWaitingQueue", + "wDev_Crypto_Conf": "sdk_wDev_Crypto_Conf", + "wDev_Crypto_Disable": "sdk_wDev_Crypto_Disable", + "wDevCtrl": "sdk_wDevCtrl", + "wDev_Disable_Beacon_Tsf": "sdk_wDev_Disable_Beacon_Tsf", + "wDevDisableRx": "sdk_wDevDisableRx", + "wDev_DisableTransmit": "sdk_wDev_DisableTransmit", + "wDev_Enable_Beacon_Tsf": "sdk_wDev_Enable_Beacon_Tsf", + "wDevEnableRx": "sdk_wDevEnableRx", + "wDev_EnableTransmit": "sdk_wDev_EnableTransmit", + "wdev_exit_sniffer": "sdk_wdev_exit_sniffer", + "wDevForceAck6M": "sdk_wDevForceAck6M", + "wDev_GetBAInfo": "sdk_wDev_GetBAInfo", + "wDev_Get_Next_TBTT": "sdk_wDev_Get_Next_TBTT", + "wDev_GetTxqCollisions": "sdk_wDev_GetTxqCollisions", + "wdev_go_sniffer": "sdk_wdev_go_sniffer", + "wDev_Initialize": "sdk_wDev_Initialize", + "wDev_Insert_KeyEntry": "sdk_wDev_Insert_KeyEntry", + "wDev_MacTim1Arm": "sdk_wDev_MacTim1Arm", + "wDev_MacTim1SetFunc": "sdk_wDev_MacTim1SetFunc", + "wDev_MacTimArm": "sdk_wDev_MacTimArm", + "wDev_MacTimSetFunc": "sdk_wDev_MacTimSetFunc", + "wDev_Option_Init": "sdk_wDev_Option_Init", + "wDev_ProcessCollision": "sdk_wDev_ProcessCollision", + "wDev_ProcessFiq": "sdk_wDev_ProcessFiq", + "wDev_remove_KeyEntry": "sdk_wDev_remove_KeyEntry", + "wDev_Reset_TBTT": "sdk_wDev_Reset_TBTT", + "wDev_Set_Beacon_Int": "sdk_wDev_Set_Beacon_Int", + "wDev_SetBssid": "sdk_wDev_SetBssid", + "wDev_SetFrameAckType": "sdk_wDev_SetFrameAckType", + "wDev_SetMacAddress": "sdk_wDev_SetMacAddress", + "wDev_SetRxPolicy": "sdk_wDev_SetRxPolicy", + "wDev_SetWaitingQueue": "sdk_wDev_SetWaitingQueue", + "WdevTimOffSet": "sdk_WdevTimOffSet", + "wd_reset_cnt": "sdk_wd_reset_cnt", + "wdt_init": "sdk_wdt_init", + "wep": "sdk_wep", + "wifi_get_channel": "sdk_wifi_get_channel", + "wifi_get_ip_info": "sdk_wifi_get_ip_info", + "wifi_get_macaddr": "sdk_wifi_get_macaddr", + "wifi_get_opmode_default": "sdk_wifi_get_opmode_default", + "wifi_get_opmode": "sdk_wifi_get_opmode", + "wifi_get_phy_mode": "sdk_wifi_get_phy_mode", + "wifi_get_sleep_type": "sdk_wifi_get_sleep_type", + "wifi_mode_set": "sdk_wifi_mode_set", + "wifi_param_save_protect": "sdk_wifi_param_save_protect", + "wifi_promiscuous_enable": "sdk_wifi_promiscuous_enable", + "wifi_promiscuous_set_mac": "sdk_wifi_promiscuous_set_mac", + "wifi_set_channel": "sdk_wifi_set_channel", + "wifi_set_ip_info": "sdk_wifi_set_ip_info", + "wifi_set_macaddr": "sdk_wifi_set_macaddr", + "wifi_set_opmode_current": "sdk_wifi_set_opmode_current", + "wifi_set_opmode_local": "sdk_wifi_set_opmode_local", + "wifi_set_opmode": "sdk_wifi_set_opmode", + "wifi_set_phy_mode": "sdk_wifi_set_phy_mode", + "wifi_set_promiscuous_rx_cb": "sdk_wifi_set_promiscuous_rx_cb", + "wifi_set_sleep_type": "sdk_wifi_set_sleep_type", + "wifi_softap_cacl_mac": "sdk_wifi_softap_cacl_mac", + "wifi_softap_deauth": "sdk_wifi_softap_deauth", + "wifi_softap_free_station_info": "sdk_wifi_softap_free_station_info", + "wifi_softap_get_config_default": "sdk_wifi_softap_get_config_default", + "wifi_softap_get_config": "sdk_wifi_softap_get_config", + "wifi_softap_get_station_info": "sdk_wifi_softap_get_station_info", + "wifi_softap_set_config_current": "sdk_wifi_softap_set_config_current", + "wifi_softap_set_config": "sdk_wifi_softap_set_config", + "wifi_softap_set_default_ssid": "sdk_wifi_softap_set_default_ssid", + "wifi_softap_set_station_info": "sdk_wifi_softap_set_station_info", + "wifi_softap_start": "sdk_wifi_softap_start", + "wifi_softap_stop": "sdk_wifi_softap_stop", + "wifi_station_ap_change": "sdk_wifi_station_ap_change", + "wifi_station_ap_check": "sdk_wifi_station_ap_check", + "wifi_station_ap_number_set": "sdk_wifi_station_ap_number_set", + "wifi_station_connect": "sdk_wifi_station_connect", + "wifi_station_dhcpc_start": "sdk_wifi_station_dhcpc_start", + "wifi_station_dhcpc_status": "sdk_wifi_station_dhcpc_status", + "wifi_station_dhcpc_stop": "sdk_wifi_station_dhcpc_stop", + "wifi_station_disconnect": "sdk_wifi_station_disconnect", + "wifi_station_get_ap_info": "sdk_wifi_station_get_ap_info", + "wifi_station_get_auto_connect": "sdk_wifi_station_get_auto_connect", + "wifi_station_get_config_default": "sdk_wifi_station_get_config_default", + "wifi_station_get_config": "sdk_wifi_station_get_config", + "wifi_station_get_connect_status": "sdk_wifi_station_get_connect_status", + "wifi_station_get_current_ap_id": "sdk_wifi_station_get_current_ap_id", + "wifi_station_scan": "sdk_wifi_station_scan", + "wifi_station_set_auto_connect": "sdk_wifi_station_set_auto_connect", + "wifi_station_set_config_current": "sdk_wifi_station_set_config_current", + "wifi_station_set_config": "sdk_wifi_station_set_config", + "wifi_station_start": "sdk_wifi_station_start", + "wifi_station_stop": "sdk_wifi_station_stop", + "wifi_status_led_install": "sdk_wifi_status_led_install", + "wpa_add_kde": "sdk_wpa_add_kde", + "wpa_attach": "sdk_wpa_attach", + "wpa_auth_for_each_sta": "sdk_wpa_auth_for_each_sta", + "wpa_auth_gen_wpa_ie": "sdk_wpa_auth_gen_wpa_ie", + "wpa_auth_sm_event": "sdk_wpa_auth_sm_event", + "wpa_auth_sta_associated": "sdk_wpa_auth_sta_associated", + "wpa_auth_sta_deinit": "sdk_wpa_auth_sta_deinit", + "wpa_auth_sta_init": "sdk_wpa_auth_sta_init", + "wpa_auth_sta_no_wpa": "sdk_wpa_auth_sta_no_wpa", + "wpa_auth_uses_mfp": "sdk_wpa_auth_uses_mfp", + "wpabuf_alloc_copy": "sdk_wpabuf_alloc_copy", + "wpabuf_alloc_ext_data": "sdk_wpabuf_alloc_ext_data", + "wpabuf_alloc": "sdk_wpabuf_alloc", + "wpabuf_concat": "sdk_wpabuf_concat", + "wpabuf_dup": "sdk_wpabuf_dup", + "wpabuf_free": "sdk_wpabuf_free", + "wpabuf_put": "sdk_wpabuf_put", + "wpabuf_resize": "sdk_wpabuf_resize", + "wpabuf_zeropad": "sdk_wpabuf_zeropad", + "wpa_cipher_key_len": "sdk_wpa_cipher_key_len", + "wpa_cipher_put_suites": "sdk_wpa_cipher_put_suites", + "wpa_cipher_to_alg": "sdk_wpa_cipher_to_alg", + "wpa_cipher_to_suite": "sdk_wpa_cipher_to_suite", + "wpa_compare_rsn_ie": "sdk_wpa_compare_rsn_ie", + "wpa_config_assoc_ie": "sdk_wpa_config_assoc_ie", + "wpa_config_bss": "sdk_wpa_config_bss", + "wpa_config_parse_string": "sdk_wpa_config_parse_string", + "wpa_config_profile": "sdk_wpa_config_profile", + "wpa_eapol_key_mic": "sdk_wpa_eapol_key_mic", + "wpa_gen_wpa_ie": "sdk_wpa_gen_wpa_ie", + "wpa_get_ntp_timestamp": "sdk_wpa_get_ntp_timestamp", + "wpa_init": "sdk_wpa_init", + "wpa_neg_complete": "sdk_wpa_neg_complete", + "wpa_parse_kde_ies": "sdk_wpa_parse_kde_ies", + "wpa_parse_wpa_ie_rsn": "sdk_wpa_parse_wpa_ie_rsn", + "wpa_parse_wpa_ie": "sdk_wpa_parse_wpa_ie", + "wpa_parse_wpa_ie_wpa": "sdk_wpa_parse_wpa_ie_wpa", + "wpa_pmk_to_ptk": "sdk_wpa_pmk_to_ptk", + "wpa_receive": "sdk_wpa_receive", + "wpa_register": "sdk_wpa_register", + "wpa_remove_ptk": "sdk_wpa_remove_ptk", + "__wpa_send_eapol": "sdk___wpa_send_eapol", + "wpa_set_bss": "sdk_wpa_set_bss", + "wpa_set_pmk": "sdk_wpa_set_pmk", + "wpa_set_profile": "sdk_wpa_set_profile", + "wpa_sm_alloc_eapol": "sdk_wpa_sm_alloc_eapol", + "wpa_sm_deauthenticate": "sdk_wpa_sm_deauthenticate", + "wpa_sm_disassociate": "sdk_wpa_sm_disassociate", + "wpa_sm_get_beacon_ie": "sdk_wpa_sm_get_beacon_ie", + "wpa_sm_mlme_setprotection": "sdk_wpa_sm_mlme_setprotection", + "wpa_sm_rx_eapol": "sdk_wpa_sm_rx_eapol", + "wpa_sm_set_state": "sdk_wpa_sm_set_state", + "wpa_supplicant_parse_ies": "sdk_wpa_supplicant_parse_ies", + "wpa_validate_wpa_ie": "sdk_wpa_validate_wpa_ie", + "wpa_write_rsn_ie": "sdk_wpa_write_rsn_ie", + "xieee80211Queue": "sdk_xieee80211Queue", + "_xt_clear_ints": "sdk__xt_clear_ints", + "_xt_context_restore": "sdk__xt_context_restore", + "_xt_context_save": "sdk__xt_context_save", + "_xt_int_enter": "sdk__xt_int_enter", + "_xt_int_exit": "sdk__xt_int_exit", + "_xt_isr_mask": "sdk__xt_isr_mask", + "_xt_isr_unmask": "sdk__xt_isr_unmask", + "_xt_read_ints": "sdk__xt_read_ints", + "_xt_tick_timer_init": "sdk__xt_tick_timer_init", + "_xt_timer_int1": "sdk__xt_timer_int1", + "_xt_timer_int": "sdk__xt_timer_int", + "xUserTaskHandle": "sdk_xUserTaskHandle", + "xWatchDogTaskHandle": "sdk_xWatchDogTaskHandle", +} + +exports_files([ + "ld/program.ld", + "ld/rom.ld", +]) + +postprocess_static_library( + name = "sdk_libmain", + library = "lib/libmain.a", + redefine = symbol_redefs, + remove = [ + "printf-stdarg.o", + "libc.o", + "xtensa_vectors.o", + "app_main.o", + "ets_timer.o", + ], + visibility = ["//visibility:public"], +) + +postprocess_static_library( + name = "sdk_libnet80211", + library = "lib/libnet80211.a", + redefine = symbol_redefs, + visibility = ["//visibility:public"], +) + +postprocess_static_library( + name = "sdk_libphy", + library = "lib/libphy.a", + redefine = symbol_redefs, + visibility = ["//visibility:public"], +) + +postprocess_static_library( + name = "sdk_libpp", + library = "lib/libpp.a", + redefine = symbol_redefs, + visibility = ["//visibility:public"], +) + +cc_import( + name = "sdk_libwpa_orig", + static_library = "lib/libwpa.a", + visibility = ["//visibility:public"], +) + +postprocess_static_library( + name = "sdk_libwpa", + library = "lib/libwpa.a", + redefine = symbol_redefs, + remove = [ + "os_xtensa.o", + ], + visibility = ["//visibility:public"], +) + +cc_import( + name = "gcc_orig", + static_library = "lib/libgcc.a", + visibility = ["//visibility:public"], +) + +postprocess_static_library( + name = "gcc", + library = "lib/libgcc.a", + remove = [ + # Object files to be removed from libgcc + # These are provided by the ROM. + "_addsubdf3.o", + "_addsubsf3.o", + "_divdf3.o", + "_divdi3.o", + "_divsi3.o", + "_extendsfdf2.o", + "_fixdfsi.o", + "_fixunssfsi.o", + "_floatsidf.o", + "_floatsisf.o", + "_floatunsidf.o", + "_floatunsisf.o", + "_muldf3.o", + "_muldi3.o", + "_mulsf3.o", + "_subdf3.o", + "_subsf3.o", + "_truncdfsf2.o", + "_udivdi3.o", + "_umoddi3.o", + "_umodsi3.o", + "_umulsidi3.o", + ], + visibility = ["//visibility:public"], +) + +cc_import( + name = "c_orig", + static_library = "libc/xtensa-lx106-elf/lib/libc.a", + visibility = ["//visibility:public"], +) + +postprocess_static_library( + name = "libc", + library = "libc/xtensa-lx106-elf/lib/libc.a", + remove = [ + # Object files to remove from libc.a + # These are provided by the ROM. + "lib_a-bzero.o", + "lib_a-memcmp.o", + "lib_a-memcpy.o", + "lib_a-memmove.o", + "lib_a-memset.o", + "lib_a-strcmp.o", + "lib_a-strcpy.o", + "lib_a-strlen.o", + "lib_a-strncmp.o", + "lib_a-strncpy.o", + "lib_a-strstr.o", + ], + visibility = ["//visibility:public"], +) + +cc_static_library( + name = "framework", + deps = [ + ":core", + ":freertos", + ":lwip", + ":open_esplibs_libmain", + ":open_esplibs_libnet80211", + ":open_esplibs_libphy", + ":open_esplibs_libpp", + ":open_esplibs_libwpa", + ], +) + +cc_static_library( + name = "libsdklib", + visibility = ["//visibility:public"], + deps = [ + ":sdk_libmain", + ":sdk_libnet80211", + ":sdk_libphy", + ":sdk_libpp", + ":sdk_libwpa", + ], +) + +cc_library( + name = "sntp", + srcs = [ + "extras/sntp/sntp.c", + "extras/sntp/sntp_fun.c", + ], + hdrs = [ + "extras/sntp/sntp.h", + ], + copts = the_kitchen_sink + [ + "-ffunction-sections", + "-fdata-sections", + "-Iexternal/esp_open_rtos/extras/sntp", + ], + visibility = ["//visibility:public"], + deps = [ + ":core_headers", + ":freertos_headers", + ":lwip_headers", + ], +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..6f6daf7 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,4 @@ +module( + name = "esp_open_rtos", + version = "0.1", +) diff --git a/bazel/cc_static_library.bzl b/bazel/cc_static_library.bzl new file mode 100644 index 0000000..76d874c --- /dev/null +++ b/bazel/cc_static_library.bzl @@ -0,0 +1,133 @@ +"""Provides a rule that outputs a monolithic static library.""" + +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") + +TOOLS_CPP_REPO = "@bazel_tools" + +def _cc_static_library_impl(ctx): + output_lib = ctx.actions.declare_file("{}.a".format(ctx.attr.name)) + output_flags = ctx.actions.declare_file("{}.link".format(ctx.attr.name)) + + cc_toolchain = find_cpp_toolchain(ctx) + + # Populate the feature configuration. This is used by the various cc library + # functions to generate contexts. + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = cc_toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features + ) + + lib_sets = [] + lib_inputs = [] + unique_flags = {} + + merged_compilation_context = cc_common.merge_compilation_contexts( + compilation_contexts = [dep[CcInfo].compilation_context for dep in ctx.attr.deps] + ) + + for dep in ctx.attr.deps: + if hasattr(dep[CcInfo].linking_context.linker_inputs, "to_list"): + lib_inputs.append(dep[CcInfo].linking_context.linker_inputs.to_list()) + else: + lib_inputs.append(dep[CcInfo].linking_context.linker_inputs) + + for lib in dep[CcInfo].linking_context.linker_inputs.to_list(): + if hasattr(lib.libraries, "to_list"): + lib_sets.append(lib.libraries) + else: + lib_sets.append(depset(direct = lib.libraries)) + unique_flags.update({ + flag: None + for flag in lib.user_link_flags + }) + + libraries_to_link = depset(transitive = lib_sets) + link_flags = unique_flags.keys() + + libs = [] + libs.extend([lib.pic_static_library for lib in libraries_to_link.to_list() if lib.pic_static_library]) + libs.extend([ + lib.static_library + for lib in libraries_to_link.to_list() + if lib.static_library and not lib.pic_static_library + ]) + + script_file = ctx.actions.declare_file("{}.mri".format(ctx.attr.name)) + commands = ["create {}".format(output_lib.path)] + for lib in libs: + commands.append("addlib {}".format(lib.path)) + commands.append("save") + commands.append("end") + ctx.actions.write( + output = script_file, + content = "\n".join(commands) + "\n", + ) + + ar_tool = cc_common.get_tool_for_action( + feature_configuration = feature_configuration, + action_name = "ar", + ) + + ctx.actions.run_shell( + command = "{} -M < {}".format(ar_tool, script_file.path), + inputs = [script_file] + libs + cc_toolchain.all_files.to_list(), + outputs = [output_lib], + mnemonic = "ArMerge", + progress_message = "Merging static library {}".format(output_lib.path), + ) + ctx.actions.write( + output = output_flags, + content = "\n".join(link_flags) + "\n", + ) + + # With the library in hand, the next step is to set up information for + # Bazel's C/C++ library to utilize the newly-created library. + library_to_link = cc_common.create_library_to_link( + actions = ctx.actions, + feature_configuration = feature_configuration, + static_library = output_lib, + #user_link_flags = ['fooxbar'] + ) + + linker_input = cc_common.create_linker_input( + libraries = depset([library_to_link]), + owner = ctx.label, + ) + + linking_context = cc_common.create_linking_context( + linker_inputs = depset([linker_input]) + ) + + # CcInfo is what is actually passed to future targets. We may need to merge + # this with the dependency's original info in order for builds to complete. + # Not sure yet. + this_cc_info = CcInfo(compilation_context = merged_compilation_context, linking_context = linking_context) + cc_infos = [this_cc_info] + # print(this_cc_info.linking_context) + # print(ctx.attr.library[CcInfo].compilation_context) + # print(ctx.attr.library[CcInfo].linking_context) + # cc_infos.append(ctx.attr.library[CcInfo]) + + merged_cc_info = cc_common.merge_cc_infos(direct_cc_infos = [this_cc_info], cc_infos = cc_infos) + # print(merged_cc_info.linking_context) + + return [ + DefaultInfo(files = depset([output_lib])), + merged_cc_info + ] + +cc_static_library = rule( + implementation = _cc_static_library_impl, + attrs = { + "deps": attr.label_list(), + "_cc_toolchain": attr.label( + default = TOOLS_CPP_REPO + "//tools/cpp:current_cc_toolchain", + ), + }, + toolchains = [TOOLS_CPP_REPO + "//tools/cpp:toolchain_type"], + fragments = ["cpp"], + incompatible_use_toolchain_transition = True, +) + diff --git a/bazel/postprocess_archive.sh b/bazel/postprocess_archive.sh new file mode 100755 index 0000000..4db3a24 --- /dev/null +++ b/bazel/postprocess_archive.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# This wrapper script takes a given archive (static library) and processes it, +# either removing/renaming symbols according to the provided arguments. + +BAZEL_EXECROOT= +ARCHIVE_TOOL= +OBJCOPY_TOOL= +INPUT_FILE= +OUTPUT_FILE= +STAGE_NUMBER=0 + +RENAME_FILE= + +ARGS=() + +set -e + +while [[ $# -gt 0 ]]; do + case $1 in + --archive) + ARCHIVE_TOOL="$2" + shift; shift; ;; + --objcopy) + OBJCOPY_TOOL="$2" + shift; shift; ;; + --input) + INPUT_FILE="$2" + shift; shift; ;; + --output) + OUTPUT_FILE="$2" + shift; shift; ;; + --remove|--redefine) + ARGS+=("$1") + shift ; ;; + -*) + echo "Unknown option $1" + exit 1 ; ;; + *) + ARGS+=("$1") + shift ; ;; + esac +done + +set -- "${ARGS[@]}" + +if [[ $# -eq 0 ]]; then + echo "No modification to be performed." + exit 2; +fi + +IN=${INPUT_FILE} +while [[ $# -gt 0 ]]; do + OUT=${OUTPUT_FILE}.stage${STAGE_NUMBER} + case $1 in + --remove) + # Avoid read-only input file. + cat $IN > $OUT && $ARCHIVE_TOOL d $OUT @$2 + + shift; shift; ;; + --redefine) + $OBJCOPY_TOOL --redefine-syms $2 --weaken $IN $OUT + shift; shift; ;; + *) + echo "Bad argument: $1" + exit 3 ; ;; + esac + STAGE_NUMBER=$((STAGE_NUMBER+1)) + IN=$OUT +done + + +mv $IN $OUTPUT_FILE diff --git a/bazel/postprocess_static_library.bzl b/bazel/postprocess_static_library.bzl new file mode 100644 index 0000000..83ed94b --- /dev/null +++ b/bazel/postprocess_static_library.bzl @@ -0,0 +1,149 @@ +# postprocess_static_library takes a prebuilt archive (static library) and +# filters out unnecessary objects / redefines symbols files. +# In ESP8266's case, this is because the ROM already provides their +# implementations. + +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", + "find_cpp_toolchain", "use_cpp_toolchain") + +def _impl(ctx): + # Find the toolchain configuration for the given platform. This is _not_ + # the same way that other languages do this, as ctx.toolchains is empty + # for C/C++ (??) + cc_toolchain = find_cpp_toolchain(ctx) + + # Populate the feature configuration. This is used by the various cc library + # functions to generate contexts. + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = cc_toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features + ) + + # We need these toolchain executables in order to process the library. + archive_tool = cc_common.get_tool_for_action( + feature_configuration = feature_configuration, + action_name = ACTION_NAMES.cpp_link_static_library, + ) + + objcopy_tool = cc_common.get_tool_for_action( + feature_configuration = feature_configuration, + action_name = "objcopy" + ) + + # Library label (target) for processing. + input_lib = ctx.file.library + + # The output library will be named after the target of this rule. + output_lib = ctx.actions.declare_file(ctx.label.name + ".a") + + # Bazel needs to know what files are inputs to a given action. + input_files = [input_lib] + + # Construct the argument list to pass to the postprocessor script + args = ctx.actions.args() + args.add_all([ + '--input', input_lib, + '--output', output_lib, + '--archive', archive_tool, + '--objcopy', objcopy_tool + ]) + + # If removing objects from the library, create a file, write the objects + # to remove into it, and add it to the list of inputs for the action. + if len(ctx.attr.remove) > 0: + rmobjs = ctx.actions.declare_file(ctx.file.library.basename + ".remove") + ctx.actions.write(rmobjs, "\n".join(ctx.attr.remove)) + input_files.append(rmobjs) + args.add_all(['--remove', rmobjs]) + + # Similar for redefining symbols. + if len(ctx.attr.redefine) > 0: + rdobjs = ctx.actions.declare_file(ctx.file.library.basename + ".redefine") + kv_pairs = [k + " " + v for k, v in ctx.attr.redefine.items()] + ctx.actions.write(rdobjs, "\n".join(kv_pairs) + "\n") + input_files.append(rdobjs) + args.add_all(['--redefine', rdobjs]) + + # TODO: Handle other ways to process a library. + + # This runs the actual script to generate the processed library. + ctx.actions.run( + inputs = input_files, + outputs = [output_lib], + tools = cc_toolchain.all_files, + arguments = [args], + executable = ctx.executable.postprocessor, + ) + + # With the library in hand, the next step is to set up information for + # Bazel's C/C++ library to utilize the newly-created library. + library_to_link = cc_common.create_library_to_link( + actions = ctx.actions, + feature_configuration = feature_configuration, + static_library = output_lib, + ) + + linker_input = cc_common.create_linker_input( + libraries = depset([library_to_link]), + owner = ctx.label, + ) + + linking_context = cc_common.create_linking_context( + linker_inputs = depset([linker_input]) + ) + + # Not yet complete: This part needs us to forward the library and its + # associated headers for targets to use without forwarding the original + # target's library (or you'll get a bunch of linking errors. + (compilation_context, compilation_outputs) = cc_common.compile( + actions = ctx.actions, + feature_configuration = feature_configuration, + cc_toolchain = cc_toolchain, + name = ctx.label.name, + ) + + # CcInfo is what is actually passed to future targets. We may need to merge + # this with the dependency's original info in order for builds to complete. + # Not sure yet. + this_cc_info = CcInfo(compilation_context = compilation_context, linking_context = linking_context) + cc_infos = [this_cc_info] + # print(this_cc_info.linking_context) + # print(ctx.attr.library[CcInfo].compilation_context) + # print(ctx.attr.library[CcInfo].linking_context) + # cc_infos.append(ctx.attr.library[CcInfo]) + + merged_cc_info = cc_common.merge_cc_infos(direct_cc_infos = [this_cc_info], cc_infos = cc_infos) + # print(merged_cc_info.linking_context) + + return [ + DefaultInfo(files = depset([output_lib])), + merged_cc_info + ] + +postprocess_static_library = rule( + implementation = _impl, + attrs = { + "library": attr.label( + allow_single_file = True, + ), + "remove": attr.string_list( + doc = "A list of modules (objects) to remove from the library.", + ), + "redefine": attr.string_dict( + doc = "A list of symbols to redefine in the library.", + ), + "postprocessor": attr.label( + default = Label("//toolchain:postprocess_archive"), + executable = True, + cfg = "exec", + ), + "_cc_toolchain": attr.label( + default = "@bazel_tools//tools/cpp:current_cc_toolchain", + ) + }, + fragments = ["cpp"], + toolchains = use_cpp_toolchain(), +)