TT扩展件microPython实现.2

TT扩展件microPython实现.1,这个是上篇,下面是下篇

GCC的目录,只为ESP芯片编译C:\Program Files (x86)\Mind+\Arduino\hardware\tools\mpython\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc-nostdlib -L    后两个是参数

-nostdlib作用:不连接系统标准启动文件和标准库文件,只把指定的文件传递给连接器。这个选项常用于编译内核、bootloader等程序,它们不需要启动文件、标准库文件。https://blog.csdn.net/weibo1230123/article/details/82817006https://www.cnblogs.com/benio/archive/2010/10/25/1860394.htmlC:\Program Files (x86)\Mind+\Arduino\hardware\dfrobot\mpython\tools\sdk\lib -L-l参数就是用来指定程序要链接的库,-l参数紧接着就是库名,那么库名跟真正的库文件名有什么关系呢?就拿数学库来说,他的库名是m,他的库文件名是libm.so,很容易看出,把库文件名的头lib和尾.so去掉就是库名了好了现在我们知道怎么得到库名,当我们自已要用到一个第三方提供的库名字libtest.so,那么我们只要把libtest.so拷贝到/usr/lib里,编译时加上-ltest参数,我们就能用上libtest.so库了(当然要用libtest.so库里的函数,我们还需要与libtest.so配套的头文件)放在/lib和/usr/lib和/usr/local/lib里的库直接用-l参数就能链接了,但如果库文件没放在这三个目录里,而是放在其他目录里,这时我们只用-l参数的话,链接还是会出错,出错信息大概是:“/usr/bin/ld: cannot find -lxxx”,也就是链接程序ld在那3个目录里找不到libxxx.so,这时另外一个参数-L就派上用场了,比如常用的X11的库,它在/usr/X11R6/lib目录下,我们编译时就要用-L/usr/X11R6/lib -lX11参数,-L参数跟着的是库文件所在的目录名。再比如我们把libtest.so放在/aaa/bbb/ccc目录下,那链接参数就是-L/aaa/bbb/ccc -ltest

C:\Program Files (x86)\Mind+\Arduino\hardware\dfrobot\mpython\tools\sdk\ld -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.libgcc.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy -u __cxx_fatal_exception -Wl,--start-group-Wl,-Bstatic &-Wl,-Bdynamic参数说明默认情况下,GCC/G++链接时优先链接动态库,如果没有动态库,则链接相应的静态库。同时,GCC/G++也提供了链接选项 -Wl,-Bstatic 和 -Wl,-Bdynamic 供用户指定链接动态库或者静态库。-Wl,-Bstatic指示跟在后面的-lxxx选项链接的都是静态库-Wl,-Bdynamic指示跟在后面的-lxxx选项链接的都是动态库。g++ -L. -o main main.cc -Wl,-Bstatic -ltest -Wl,-Bdynamic1前面的 -Wl,-Bstatic指示链接libtest.a静态库,后面的 -Wl,-Bdynamic指示链接系统动态库。选项说明-shared产生共享对象-static使用静态链接,默认是动态链接-e xx指定xx 为程序的入口函数-fpic产生地址无关代码,较小且较快,但某些平台会有限制符号数量和代码长度,-fPIC产生地址无关代码,没有限制。一般用这个-no-builtinGCC编译器提供了很多内置函数(Built-in function),会把常用的C库函数替换成编译的内置函数,以优化功能,这个选项就是关闭内置函数功能,不要被其优化在开发一个项目时,使用了非常多的第三方.a静态库文件,导致编译出的可执行文件非常大。这样一是占用ROM空间,二是会导致程序启动加载速度变慢(项目对启动时间非常敏感)。其实,这些静态库中的函数,并非所有都有调用,项目只使用了其中小部分。这种情况下,gcc的“-Wl,–gc-sections”参数,就非常有用。补充说明:想要达到生成最终可执行文件,只链接.a库中用到的函数,需要在编译生成.a库时,就带有-ffunction-sections参数。https://blog.csdn.net/wuu19/article/details/100725025--gc-sections -Wl参数说明英文原版的-Wl,–gc-sections解释说明如下:6.3.3.2 Compilation optionsThe operation of eliminating the unused code and data from the final executable is directly performed by the linker.In order to do this, it has to work with objects compiled with the following options: -ffunction-sections -fdata-sections.These options are usable with C and Ada files. They will place respectively each function or data in a separate section in the resulting object file.Once the objects and static libraries are created with these options, the linker can perform the dead code elimination. You can do this by setting the -Wl,–gc-sections option to gcc command or in the -largs section of gnatmake. This will perform a garbage collection of code and data never referenced.If the linker performs a partial link (-r linker option), then you will need to provide the entry point using the -e / --entry linker option.Note that objects compiled without the -ffunction-sections and -fdata-sections options can still be linked with the executable. However, no dead code elimination will be performed on those objects (they will be linked as is).The GNAT static library is now compiled with -ffunction-sections and -fdata-sections on some platforms. This allows you to eliminate the unused code and data of the GNAT library from your executable.

https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html大致说明如下:在编译C、Ada源文件(C++也可以),在gcc/g++编译选项中增加-ffunction-sections、-fdata-sections,在编译生成的.o目标文件中,会将每个函数或数据段,放在各种单独独立的section中;在链接生成最终可执行文件时,如果带有-Wl,--gc-sections参数,并且之前编译目标文件时带有-ffunction-sections、-fdata-sections参数,则链接器ld不会链接未使用的函数,从而减小可执行文件大小;如果使用了-r的链接参数,来产生重定位的输出,需要显示的调用-e参数来指定程序入口。否则-Wl,--gc-sections不会生效。c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\drone.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_fonts.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_gamesirt1d.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_libs.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_matrix.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_matrixeffect.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_protocol.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_rgb.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_rgbeffect.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_shell.cpp.o c:\program files (x86)\mind+\arduino\static\libraries\rmtt_libs\telloesp32\rmtt_tof.cpp.o

这些是TT的编译库c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\ble2902.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\ble2904.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleaddress.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleadvertiseddevice.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleadvertising.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\blebeacon.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\blecharacteristic.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\blecharacteristicmap.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleclient.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bledescriptor.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bledescriptormap.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bledevice.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleeddystonetlm.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleeddystoneurl.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleexceptions.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\blehiddevice.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleremotecharacteristic.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleremotedescriptor.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleremoteservice.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\blescan.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\blesecurity.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleserver.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleservice.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleservicemap.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleuuid.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\bleutils.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\blevalue.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\freertos.cpp.o c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\ble\telloesp32\generalutils.cpp.o

c:\program files (x86)\mind+\arduino\static\hardware\dfrobot\mpython\libraries\wire\telloesp32\wire.cpp.o

我觉得是从这个库里面

这么大,我觉得是抽取以下的库编译到固件里面.只是猜想

这个core文件还是分布在各个地方的.还是不清楚作用-lgcc -lopenssl -lbtdm_app -lfatfs -lwps -lcoexist -lwear_levelling -lesp_http_client -lprotobuf-c -lhal -lnewlib -ldriver -lbootloader_support -lpp -lfreemodbus -lmesh -lsmartconfig -ljsmn -lwpa -lethernet -lphy -lapp_trace -lconsole -lulp -lwpa_supplicant -lfreertos -lbt -lmicro-ecc -lesp32-camera -lcxx -lxtensa-debug-module -ltcp_transport -lmdns -lvfs -lesp_ringbuf -lsoc -lcore -lfb_gfx -lsdmmc -llibsodium -lcoap -ltcpip_adapter -lprotocomm -lesp_event -limage_util -lc_nano -lesp-tls -lasio -lrtc -lspi_flash -lwpa2 -lwifi_provisioning -lesp32 -lface_recognition -lapp_update -lnghttp -lspiffs -lface_detection -lespnow -lnvs_flash -lesp_adc_cal -llog -ldl_lib -lsmartconfig_ack -lexpat -lm -lfr -lmqtt -lc -lheap -lmbedtls -llwip -lnet80211 -lesp_http_server -lpthread -ljson -lesp_https_ota -lfd -lstdc++ -Wl,--end-group -Wl,-EL -o

这个地方是编译加入的库一览GNU链接器几个开关项的解释:-lm -lc -lgcc-lm 代表链接器将连接GCC的数学库libm.a-lc 代表链接器将连接GCC的标准C库libc.a-lgcc 代表链接器将连接GCC的支持库libgcc.a在连接时,这些库的排列顺序一般为: -lm -lc -lgcchttps://blog.csdn.net/cos_sin_tan/article/details/8423397–start-group archives --end-groupThe archives should be a list of archive files. They may be either explicit file names, or `-l’ options. The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved. Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.正常情况,链接的时候库文件只会按它们出现在命令行的顺序搜索一遍,如果包里有未定义的引用标号,而且该包还被放在命令行的后面,这样链接器就无法解决该标号的引用问题。通过给包分组,这些包可以被循环搜索直到所有的引用都可以解决为止。使用该选项将降低性能。只有在无法避免多个包之间互相引用的情况下才使用。用法示例:cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \-T $(vmlinux-lds) $(vmlinux-init)                          \--start-group $(vmlinux-main) --end-group                  \ $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o FORCE ,$^

在已经编译的文件里面确实是这样的,就是有的参数是重复出现的,不知道怎么办,就是不知道gcc是怎么处理这个参数重复的

是一个内存的布局文件esptool.py" --chip esp32 elf2image --flash_mode "dio" --flash_freq "80m" --flash_size "2MB" -o这个是上传工具的参数,可以看到频率是80Mhzflash是2MB还有一个参数,我需要自己查文档项目使用了223976字节,占用了(17%)程序存储空间,余留1086744字节,最大为1310720字节。全局变量使用了16388字节,(6%)的动态内存,余留278524字节局部变量,最大为294912字节。 可以输出空间情况esptool.py --chip esp32 --port COM8 --baud 921600 read_flash 0x400000 4 真正的上传参数esptool.py v2.3.1Connecting.......Chip is ESP32D2WDQ5 (revision 1)Features: WiFi, BT, Dual Core, Embedded Flash, VRef calibration in efuseUploading stub...Running stub...Stub running...Changing baud rate to 921600Changed.这个是正在的刷写logRead 4 bytes at 0x400000 in 0.0 seconds (2.6 kbit/s)...Hard resetting via RTS pin...4 (100 %)4%,中断一下.继续上传C:\Program Files (x86)\Mind+\python36\python C:\Program Files (x86)\Mind+\Arduino\hardware\tools\mpython\esptool.py --chip esp32 --port COM8 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Program Files (x86)\Mind+\Arduino\fw\telloesp32\boot_app0.bin 0x1000 C:\Program Files (x86)\Mind+\Arduino\fw\telloesp32\bootloader_dio_40m.bin 0x10000 C:\Users\yunswj\AppData\Local\DFScratch\build\dfrobot.ino.bin 0x8000 C:\Users\yunswj\AppData\Local\DFScratch\build\dfrobot.ino.partitions.bin 0x150000 C:\Program Files (x86)\Mind+\Arduino\fw\telloesp32\spiffs.bin接着又开始刷写后面跟着5个bin文件esptool.py v2.3.1Connecting....Chip is ESP32D2WDQ5 (revision 1)Features: WiFi, BT, Dual Core, Embedded Flash, VRef calibration in efuseUploading stub...Running stub...Stub running...Changing baud rate to 921600Changed.Configuring flash size...Auto-detected Flash size: 2MBesptool.py v2.3.1正在连接...。芯片是ESP32D2WDQ5(版本1)功能:WiFi,BT,双核,嵌入式闪存,易用的VRef校准上载存根...正在运行存根...存根正在运行...将波特率更改为921600变了配置闪光灯大小...自动检测到的闪存大小:2MB又开始调用了Writing at 0x00000000... (2 %)Erasing flash (this may take a while)...Chip erase completed successfully in 4.2sCompressed 8192 bytes to 47...Writing at 0x0000e000... (100 %)Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 8158.8 kbit/s)...Hash of data verified.Flash params set to 0x021fCompressed 15872 bytes to 10320...Writing at 0x00001000... (100 %)Wrote 15872 bytes (10320 compressed) at 0x00001000 in 0.1 seconds (effective 925.0 kbit/s)...Hash of data verified.Compressed 224144 bytes to 108799...写在0x00000000 ...(2%)正在擦除闪光灯(这可能需要一段时间)...芯片擦除在4.2秒内成功完成压缩8192字节为47 ...写在0x0000e000 ...(100%)在0.0秒内以0x0000e000(有效8158.8 kbit / s)写入8192字节(压缩47)。验证数据的哈希值。Flash参数设置为0x021f将15872字节压缩到10320 ...写在0x00001000 ...(100%)在0.1秒(有效925.0 kbit / s)中以0x00001000写入15872字节(压缩的20320)...验证数据的哈希值。压缩224144字节为108799 ...又一段logWriting at 0x00010000... (14 %)Writing at 0x00014000... (28 %)Writing at 0x00018000... (42 %)Writing at 0x0001c000... (57 %)Writing at 0x00020000... (71 %)Writing at 0x00024000... (85 %)Writing at 0x00028000... (100 %)Wrote 224144 bytes (108799 compressed) at 0x00010000 in 1.7 seconds (effective 1041.6 kbit/s)...Hash of data verified.Compressed 3072 bytes to 118...Writing at 0x00008000... (100 %)Wrote 3072 bytes (118 compressed) at 0x00008000 in 0.0 seconds (effective 2731.9 kbit/s)...Hash of data verified.Compressed 720896 bytes to 1330...Writing at 0x00150000... (100 %)Wrote 720896 bytes (1330 compressed) at 0x00150000 in 0.0 seconds (effective 262322.2 kbit/s)...Hash of data verified.Leaving...Hard resetting via RTS pin...最后一段日志,上传成功

(0)

相关推荐

  • dfrobot-arduino uno r3引脚图

    Arduino Uno R3开发板的引脚分配图包含14个数字引脚.6个模拟输入.电源插孔.USB连接和ICSP插头.引脚的复用功能提供了更多的不同选项,例如驱动电机.LED.读取传感器等.下图为Ard ...

  • Phyphox外挂压强计及Nano 33测试

    自Phyphox发布了Arduino BLE扩展库,已经能够方便地为Phyphox扩充测量电压的功能--一旦一个物理量被转换到电压测量,则这物理量就可被测量了. 这便是教材--用于教学--传感器原理的 ...

  • 基于具有Arduino Leonardo的树莓派扩展板的介绍

    描述 一. 前言 Raspberry PI树莓派是一个具备高级功能的嵌入式Linux主板,可以实现完整的计算机功能,近些年来因为树莓派的便宜,方便使用等诸多因素导致树莓派非常火热,受到众多开发者的热爱 ...

  • 使用Arduino Nano 33 BLE/Sensor创作Phyphox实验研究

    有些过于技术性,只简略记录大概. 1.概念 Arduino Nano 33BLE/Sensor是不同于传统Arduino开发板的新型板子,去年才发行,它们使用3.3V电源,微安级低功耗,高度集成了9种 ...

  • TT扩展件microPython实现.1

    这边选择mPy,会自动上传安装mPy的固件 可以看到tt扩展件内部有什么 这边也可以从本地来加载二进制的固件 可以看到文件后缀是bin文件 这边有几个二进制文件 这个地方也可以看到固件的版本,是0.0 ...

  • Dji TT扩展件与TT使用USB端串口通讯.下

    void setup() { Serial.begin(115200); delay(100); Serial.println(); Serial1.begin(0, SERIAL_8N1, -1, ...

  • Dji TT扩展件与TT使用USB端串口通讯.上

    我觉得这个+应该是= 不然这个句子我一直读不通 好,我们具体的发送方式拿到了 来搜索 发送命令的C++版本,这个是最重要的 串口的定义,是用了这个两个引脚来控制和接受飞机回传的信息 特别的,在一个de ...

  • Dji TT无人机扩展件ESP32芯片(D2WDQ5)

    就是蓝色位置的芯片 项目使用了964036字节,占用了(74%)程序存储空间,余留346684字节,最大为1310720字节.全局变量使用了40760字节,(14%)的动态内存,余留254152字节局 ...

  • RoboMaster TT 无人机microPython编程.1

    感谢小马的美图 这个Mind+中有支持TT扩展件MicroPython实现,今日做个整理以及有一些实验要做: from machine import *from RMTTLib import *i2c ...

  • RoboMaster TT 无人机microPython编程.3

    只是积木的功能少而已,事实上,代码编写是少不了的. 这里我们用vscode来编写 设备快速连接(串口.网络.USB) 支持基于 MicroPython 的代码智能补全与语法检查 支持 MicroPyt ...

  • RoboMaster TT 无人机microPython编程.2

    还记得我们说的读取上次的状态吗,这个就是所有上次的状态 print(protocol.getTelloStatusWithName("temph")) print(protocol ...

  • 瑜伽老宏大了..就像一部交响乐,体位法练习单薄的就一件小乐器

    在大多数人的眼里,瑜伽就是一个一个的体式(姿势,pose).人们会经常说摆个瑜伽姿势.但是根据印度哈达瑜伽的传统(所有练习体式的瑜伽都属于哈达瑜伽流派)体式只是内修的一个手段,锻炼身体,减肥塑形,理疗 ...

  • 别为所谓“自律”费了老鼻子劲,你只要把瑜伽练习变成一件“小事”

    如果要把瑜伽体式练习作为一种自律的修行坚持下去,这样的想法听上去就"沉甸甸"的,做起来恐怕也是肯定是比较难的.因此很多人望而却步,瑜伽对于这些人来说就变成隔三差五的拉伸, 健身课, ...