Hello,
Follow-up to my previous attemps on getting a working bare metal USB stack with DMA on the F1C100S, at first i found the Melis USB stack sources and spent several hours to modify them in order to compile as a standalone stack, the files can be found here USB_STACK_MELIS.zip.
It can compile but there is some calls to external functions (replaced by dummy functions), mostly in ePos, the RTOS on which Melis is based. So i decided that this is not ideal because ultimately this USB stack seems to rely on the presence of an RTOS and i dont want any RTOS.
So i have finally ported a complete bare-metal USB stack with DMA, it is the Sunxi official USB stack, extracted from u-boot, i had to spend several hours to fix all include path and sources files so that it can be compiled. The files can be found here USB_STACK_SUNXI.zip. I used gcc-arm-none-eabi 5_2-2015q4 but it should work with any gcc-arm.
To do the transplant and avoid worries on the makefile and linker script i started from an empty cross-GCC project in Eclipse and used the internal builder.
After much struggle the stack finally compiles, all dependencies are satisfied and the linker is able to link, however to get an usable Eclipse project all this stack has to be integrated into the already working bare-metal template (minimal-f1c100s), which has a working makefile and linker script and deals with the bootloader.
In the USB stack i had to integrate two assembly files : vectors.S and start.S, these two files contain some references used in the USB stack initialisation, namely IRQ, FIQ and few other things. It is a problem because the template (minimal-f1c100s) already has it own start.S file and it will be in conflict, also the interrupt vector is already declared. I am sure it is possible to get rid of vector.S and start.S from the USB stack and integrate all the sources into minimal-f1c100s directly, but I am having troubles to achieve this and i need some help with this task.
Ultimately it would be great to make an Eclipse project template which can manage the makefile itself so we dont have to edit it by hand. Contrary to Keil, Eclipse is working on all OS (windows, MacOS and Linux) it is free to use and convenient with GCC and a debugger.
I think it would be profitable to all F1C100S bare-metal users if we can put together an Eclipse template with the existing source code minimal-f1c100s, all it drivers, the USB stack and automatic makefile management. So that everyone could develop bare-metal application easily without worry for makefile and linker file hand editing, and use a debugger if they want to.
If anyone is willing to help with this process, please share your knowlhedge for the benefit of all.
Why would someone need to run F1C100S without Linux or RTOS?
because all the CPU power available is needed for the realtime signal processing, the ARM926EJ-S is a little bit old and it doesnt have some more recent instructions like SIMD found on Cortex-M serie, so the DSP is less efficient, there is also no real hardware floating point, there is a FVP (vector floating point) but for some reason GCC seems to consider it as SoftFloat. I tried to run my signal processing on Linux (5.2, with USB+DMA) and the peformance was catastrophic, when i tried to run the exact same signal processing in bare metal the performance increase was over 250%, that is why i need bare metal.
Why would someone need bare-metal USB HOST?
The data acquisition is done with an external chipset which only provide USB 2.0 interface, there is no SPI or anything else.
Why would someone need USB HOST with DMA?
Quite a lot of data is acquired in realtime continuously, DMA is necessary to achieve data acquisition without loading and interrupting the CPU which does not have much free time due to the ongoing signal processing (double buffering).
你好,
在我以前尝试在F1C100S上获得具有DMA的可用裸机USB堆栈的尝试之后,我首先找到了Melis USB堆栈源,并花了几个小时对其进行修改,以便将其编译为独立的堆栈,在此处找到 USB_STACK.zip 。
它可以编译,但是有一些对外部函数的调用(由伪函数代替),主要是在ePos(Melis所基于的RTOS)中。因此,我认为这不是理想的选择,因为最终该USB堆栈似乎依赖于RTOS的存在,因此我不希望任何RTOS。
因此,我终于移植了带有DMA的完整裸机USB堆栈,它是从u-boot提取的Sunxi官方USB堆栈,我不得不花几个小时来修复所有包含路径和源文件,以便可以对其进行编译。可以在 USB_STACK_SUNXI.zip 中找到文件。我使用了gcc-arm-none-eabi 5_2-2015q4,但它应该可以与任何gcc-arm一起使用。
为了进行移植并避免对makefile和链接程序脚本的担心,我从Eclipse中一个空的跨GCC项目开始,并使用了内部生成器。
经过艰苦的努力,堆栈最终得以编译,所有的依赖关系都得到了满足,并且链接器可以链接,但是要获得可用的Eclipse项目,请将所有这些堆栈集成到已经工作的裸机模板(minimal-f1c100s)中,该模板具有一个工作的makefile和链接程序脚本,并处理引导程序。
在USB堆栈中,我必须集成两个程序集文件:vector.S和start.S,这两个文件包含USB堆栈初始化中使用的一些引用,即IRQ,FIQ和其他一些东西。这是一个问题,因为模板(minimal-f1c100s)已经具有其自己的start.S文件,并且将发生冲突,并且中断向量也已声明。我确信可以摆脱USB堆栈中的vector.S并启动.S并将所有源直接集成到minimal-f1c100s中,但是我在实现此目标方面遇到了麻烦,因此我需要一些帮助。
最终,制作一个可以管理makefile本身的Eclipse项目模板将是很棒的,因此我们不必手动对其进行编辑。与Keil相反,Eclipse可以在所有OS(Windows,MacOS和Linux)上使用,可以免费使用,并且可以与GCC和调试器一起使用。
我认为,如果我们可以将Eclipse模板与现有的源代码minimal-f1c100s,所有驱动程序,USB堆栈和自动makefile管理放在一起,对所有F1C100S裸机用户都是有利的。这样,每个人都可以轻松开发裸机应用程序,而不必担心makefile和linker文件的手工编辑,并在需要时使用调试器。
如果有人愿意在此过程中提供帮助,请分享您的知识以造福所有人
为什么有人需要在没有Linux或RTOS的情况下运行F1C100S?
因为实时信号处理需要所有可用的CPU能力,所以ARM926EJ-S有点旧,并且没有诸如Cortex-M系列上的SIMD之类的一些最新指令,因此DSP的效率较低,因此,没有真正的硬件浮点,有一个FVP(矢量浮点),但是由于某种原因,GCC似乎将其视为SoftFloat。我尝试在Linux(5.2,带有USB + DMA)上运行信号处理,而性能却是灾难性的,当我尝试在裸机上运行完全相同的信号处理时,性能提高了250%以上,这就是为什么我需要裸机的原因金属。
为什么有人需要裸机USB HOST?
数据采集是通过外部芯片组完成的,该芯片组仅提供USB 2.0接口,没有SPI或其他任何东西。
为什么有人需要带有DMA的USB HOST?
连续不断地实时采集大量数据,DMA是实现数据采集而不需要加载和中断CPU的必要条件,由于正在进行的信号处理(双重缓冲),CPU没有太多的空闲时间。
最近编辑记录 hoel (2020-05-29 00:58:28)
离线
离线
支持一下。支持裸机开发
离线
以下是 xboot 在QQ群的回复:
主要问题是如何集成usb栈,然后中断不知道该如何用,
不知道minimal-f1c100s有没有移植xboot的中断框架,
如果有移植的话,那么支持中断也是很容易的一件事,
不过,可以建议你直接在xboot上,移植usb栈,所有组件都是完整的。
The USB stack already has the interrupt framework. I fear It will take a lot of efforts to adapt the USB stack to xboot, i want to avoid that, the stack is already working standalone, the only adaptation is the f1c100s.ld linker file. I made good progress yesterday, now the Eclipse project can compile and produce the .hex and .bin, the only remaining problem is to adapt the linker file f1c100s.ld, because currently it includes some object fils (.0) and Eclipse is not happy about it ("multiple definition of ..." error).
If i comment the included .o files in f1c100s.ld then the linking is successful.
USB堆栈已具有中断框架。 恐怕要使USB堆栈适应xboot会花费很多精力,我想避免这种情况,该堆栈已经可以独立工作,唯一的适应是f1c100s.ld链接器文件。 我昨天取得了良好的进展,现在Eclipse项目可以编译并生成.hex和.bin,唯一剩下的问题是改编链接器文件f1c100s.ld,因为当前它包含一些对象fils(.0),而Eclipse没有。 很高兴(“ ...的多个定义”错误)。
如果我注释了包含的.o文件,则链接成功。
原始的f1c100s.ld
带有.o的f1c100s.ld进行了评论
项目设置
最近编辑记录 hoel (2020-05-29 18:31:15)
离线
以下是 xboot 在QQ群的回复:
主要问题是如何集成usb栈,然后中断不知道该如何用,
不知道minimal-f1c100s有没有移植xboot的中断框架,
如果有移植的话,那么支持中断也是很容易的一件事,
不过,可以建议你直接在xboot上,移植usb栈,所有组件都是完整的。
下载了官方文件,打开了Eclipse项目,设置PLATFORM和CROSS_COMPILE,甚至无法构建...
离线
这玩的都很高端啊!
离线
改为:
PLATFORM ?=arm32-f1c100s
谢谢老板
离线
谢谢老板
老板你的中文说得很6嘛,听口音不像是本地人啊?
离线
改为:
PLATFORM ?=arm32-f1c100s
最终失败,我尝试了F1C100S上的二进制文件,它不起作用,UART上没有任何内容
离线
离线
改为:
PLATFORM ?=arm32-f1c100s
解决了第一个问题,我在macos上,所以我添加了mksunxi,但是仍然存在MKZ问题,提供的版本仅在linux上有效,无法在macos上执行,并且未提供源文件。 应该提供MKZ的源文件和makefile,以便我们至少可以在macOS上构建它
copy from `../output/xboot' [elf32-littlearm] to `../output/xboot.bin' [binary]
Make header information for brom booting
bootloader size= 2200
The bootloader head has been fixed
/bin/sh: arch/arm32/mach-f1c100s/tools/linux/mkz: cannot execute binary file
make[1]: *** [xend] Error 126
make: *** [all] Error 2
离线
自行编译mkz之类的工具,源码目录里有。
hoel@iMac-de-Hoel-7 ~/Downloads/xboot-master/developments/mkz $ make
[LD] Linking mkz
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mkz] Error 1
无法在macOS上静态链接crt0.o
但是当我从生成文件中删除-static标志时,弹出另一个错误
hoel@iMac-de-Hoel-7 ~/Downloads/xboot-master/developments/mkz $ make
[LD] Linking mkz
ld: unknown option: --cref
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mkz] Error 1
Try removing `-static` from LDFLAGS in the Makefile. The reason being is
that on macOS, there isn't a static version of the crt0.o library.See
https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag
for details.
最近编辑记录 hoel (2020-05-29 22:25:56)
离线
再把 --cref 删掉
$(NAME) : $(OBJS)
@echo [LD] Linking $@
@$(CC) $(LDFLAGS) $(LIBDIRS) -Wl,-Map=$@.map $^ -o $@ $(LIBS)
hoel@iMac-de-Hoel-7 ~/Downloads/xboot-master/developments/mkz $ make
[LD] Linking mkz
ld: unknown option: -Map=mkz.map
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mkz] Error 1
离线
最后
$(NAME) : $(OBJS)
@echo [LD] Linking $@
@$(CC) $(LDFLAGS) $(LIBDIRS) -Wl $^ -o $@ $(LIBS)
hoel@iMac-de-Hoel-7 ~/Downloads/xboot-master/developments/mkz $ make
[CC] ecdsa256.c
[CC] main.c
[CC] sha256.c
[CC] lz4/lz4.c
[CC] lz4/lz4frame.c
[CC] lz4/lz4hc.c
[CC] lz4/xxhash.c
[LD] Linking mkz
16:34:12 **** Incremental Build of configuration Default for project xboot ****
make all
[ROMDISK] Packing romdisk
[CC] init/version.c
[AS] driver/block/romdisk.S
[LD] Linking ../output/xboot
[OC] Objcopying ../output/xboot.bin
copy from `../output/xboot' [elf32-littlearm] to `../output/xboot.bin' [binary]
Make header information for brom booting
bootloader size= 2200
The bootloader head has been fixed
Compressed 3990016 bytes into 2613615 bytes ==> 65.503873% [C][S]
16:34:15 Build Finished (took 2s.868ms)
最近编辑记录 hoel (2020-05-29 22:34:55)
离线
那是我开机后得到的全部,还有更多期望吗?
_ _
_ _ | |___ _____ _____ _| |_
\ \/ /| _ | _ | _ |_ _| (C) 2007-2020
) ( | |_| | |_| | |_| | | |____JIANJUN.JIANG__
/_/\_\|_____|_____|_____| |_____________________|
V3.0.0 (May 29 2020 - 16:34:12) - [sast-kk131][SAST KK131 Digital Player Based On Allwinner F1C100S]
[ 0.000000] Probe device 'blk-romdisk.0' with blk-romdisk
离线
搞定了?那可以为所欲为了。
坐等大神搞定usb host.
是的,一旦它正常工作,我将移植USB HOST堆栈
离线
有一个 lua 的启动脚本,你看下readme.md 吧。
LUA实际上是我要在裸机系统中使用的最后一件事,这是胡说八道。
离线
void xboot_main(void)
{
/* Do initial memory */
do_init_mem();
/* Do initial scheduler */
do_init_sched();
/* Do initial vfs */
do_init_vfs();
/* Do all initial calls */
do_initcalls();
/* Do show logo */
do_showlogo();
/* Do auto mount */
do_automount();
/* Do auto boot */
do_autoboot();
//#if defined(CONFIG_SHELL_TASK) && (CONFIG_SHELL_TASK > 0)
/* Create shell task */
struct task_t * task = task_create(scheduler_self(), "shell", shell_task, NULL, 0, 0);
/* Resume shell task */
task_resume(task);
//#endif
/* Scheduler loop */
scheduler_loop();
/* Do all exit calls */
do_exitcalls();
}
IT应该显示一个shell提示,但没有任何提示,因此显然不起作用。
我也不认为xboot在这里会有所帮助,这是一个旨在适合许多体系结构的完整系统,与裸机相反。 我既不想也不打算了解Xboot的详细信息,也不想打算为它编写驱动程序,因为我没有用过这种系统。
我想要的只是将USB HOST堆栈移植到裸机上,无论如何,中断例程已经包含在堆栈中,我认为Xboot对我来说是行不通的。 什么也不做时已经是4MB了。
最近编辑记录 hoel (2020-05-29 23:13:50)
离线
老板你的中文说得很6嘛,听口音不像是本地人啊?
哈哈,谢谢,我只是法国工程师,但我非常喜欢中国,而我的同事是中国人
离线
离线
哎,搞这个芯片真不容易,好不容易吧uvc iso调试出来,发现速度不行
离线