Chen Yulin's BlogChen Yulin's Blog
HomeArchivesCategoriesTagsAbout
STM32 Development on Linux
Posted 2024-05-21Updated 2025-05-13Note6 minutes read (About 833 words)

STM32 Development on Linux

System used: Archlinux

Pre-requirements

  • c language server (for completion, diagnostics), e.g. clangd
  • A code editor that use language server, e.g. vscode, vim/neovim

Install Related Softwares

STM32CubeMX

STM32CubeMX is mainly responsible for generating the project with your configuration.

For Distro like Ubuntu/Debain, you can go to the ST official site
Or you can install the software through distro repository

1
yay -S stm32cubemx

For Arch, you need to modify the AUR repository (I mean, maybe the maintainer doesn’t do a good job).
The URL for the repository:https://aur.archlinux.org/packages/stm32cubemx

First clone the repository

1
git clone https://aur.archlinux.org/stm32cubemx.git

Modify the required jdk version in file stm32cubemx.sh
from exec archlinux-java-run --min 17 -- -jar /opt/stm32cubemx/STM32CubeMX "$@" to exec archlinux-java-run --min 17 --max 20 -- -jar /opt/stm32cubemx/STM32CubeMX "$@"

Then build and install the STM32CubeMX

1
makepkg --noconfirm --skipinteg -si

Since STM32CubeMX is not compatible with jdk22 (which is the default jdk that arch is currently using), you need to install jdk17 through yay -S jdk17-openjdk

Then you can start STM32CubeMX by running stm32cubemx, and hopefully, everything is fine.

Compiler

Use arm-none-eabi-gcc

1
2
yay -S arm-none-eabi-gcc
yay -S arm-none-eabi-newlib

Debugger

Use OpenOCD to burn and debug STM32 through STLink v2 (the blue USB device provided by us).

1
yay -S openocd

Setup Your STM32 Project

Open your STM32CubeMX, follow the instruction of Lab1.pdf to configure your project.

NOTE: In Project Manage -> Project -> Project Settings -> Toolchain / IDE, use Makefile/CMake.

Generate the code and go to the project directory (with Makefile/CMakeLists.txt in the directory).

Then you need to generate the compile_commands.json for clangd to recognize the project.

Makefile

1
bear -- make

CMake

1
cmake -S ./ -B ./build

Build Project

Makefile

1
make

Then target binary file is ./build/<Project Name>.bin

CMake

1
cmake --build ./build

Then target binary file is ./build/<Project Name>.elf

Load to STM32F103C8T6

Use OpenOCD to load the binary file to the board.

1
sudo openocd -f /usr/share/openocd/scripts/interface/stlink.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program ./build/<Project Name>.bin reset exit 0x8000000"

Result

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1000 kHz
Info : STLINK V2J37S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.222587
Info : [stm32f1x.cpu] Cortex-M3 r1p1 processor detected
Info : [stm32f1x.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000dc8 msp: 0x20005000
** Programming Started **
Info : device id = 0x20036410
Info : flash size = 64 KiB
** Programming Finished **
** Resetting Target **
shutdown command invoked

NOTE: In different Distro, the cfg file for OpenOCD may locate in different directories. You need to find it by yourselves.

By the way, if you use CMake

Note: When uploading binary file to STM32, it’s recommended to use .bin file instead of .elf file.
Please use the following script to convert the .elf to .bin and upload.

1
2
3
4
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
cmake --build ./build
arm-none-eabi-objcopy -O binary -S ./build/*.elf ./build/target.bin
sudo openocd -f /usr/share/openocd/scripts/interface/stlink.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program ./build/target.bin reset exit 0x8000000"

Debug

You have three possible choices. I recommend using Ozone.

openocd+gdb+gdbfrontend(not recommended)

reference:
https://rohanrhu.github.io/gdb-frontend/tutorials/embedded-debugging/

openocd+vscode+PlatformIO (not recommended)

reference:
https://blog.csdn.net/qq_41757528/article/details/127741620

Segger Ozone!!!

reference:
https://blog.csdn.net/weixin_41572450/article/details/124710818

Maybe the best debug tool for stm32

To use segger ozone, you need a different linker called jlink (originally we use st-link v2). You need to buy this linker first (maybe on Taobao or Amazon).

Install Ozone through:

1
yay -S ozone

Setup of ozone project:

  • Start Ozone
  • Choose Device
    • Device: STM32F103C8
    • Register Set: Cortex-M3
    • Peripherials (optional): /opt/SEGGER/Ozone/Config/Peripherals/STM32F103xx.svd
  • Connection Settings
    • Target Interface: SWD
    • Target Interface Speed: 4MHz
    • Host Interface: USB
  • Program File: select the binary file you have built (.elf is recommended).

Debug:

set some breakpoints and watch some variables of your interest.
Press the green “power” icon on the upper left corner to start (upload the program and start the debugging process)
Press the blue “play” icon besides “power” to continue.

Posted 2024-05-19Updated 2025-05-13杂记43 minutes read (About 6391 words)

咖喱二三事

Here's something encrypted, password is required to continue reading.
Read more
Unix Network Programming SRC
Posted 2024-05-16Updated 2025-05-13Notea minute read (About 134 words)

Unix Network Programming SRC

The source code repository:https://github.com/unpbook/unpv13e

Preparation

1
git clone https://github.com/unpbook/unpv13e

Configure the makefile for your system:

1
CC=gcc CFLAGS=-w CPPFLAGS=-w ./configure    

In archlinux, if you use ./configure directly, you will get Wimplicit compile error in the following steps.

Build the dependence library.

1
2
3
4
5
6
cd lib
make
cd ../libfree
make
cd ../libroute
make

You can test by using the sample program

1
2
3
cd ../intro
make daytimetcpcli
./daytimetcpcli 127.0.0.1

If you get error

1
connect error: Connection refused

You need to install xinetd, configure it and start the service

1
2
3
yay -S xinetd
nvim /etc/xinetd.d/daytime # set `disable` from `yes` to `no`
systemctl start xinetd

And run daytimetcpcli again, you will get something like

1
16 MAY 2024 14:09:07 CST

Then, you are all set.

《中国太阳》读书会p5
Posted 2024-05-16Updated 2025-05-13读读噜7 minutes read (About 1001 words)

《中国太阳》读书会p5

原文

「中国太阳不去火星。」
庄宇迷惑地看着水娃,「那去哪里?木星?」
「也不是木星,去更远的地方。」
「更远?去海王星?去冥王……」庄宇突然顿住,呆呆地盯着水娃看了好一会儿,「天啊,你不会是说……」
水娃坚定地点点头:「是的,中国太阳将飞出太阳系,成为恒星际飞船!」
与庄宇一样,全世界顿时目瞪口呆。
庄车两眼平视前方,机械地点点头:「好吧,就让我们不当你是在开玩笑,你让我大概估算一下……」说着他半闭起双眼开始心算。
「我已经算好了:借助太阳的光压,中国太阳最终将加速到光速的十分之一,考虑到加速所用的时间,大约需四十五年时间到达比邻星。然后再借助比邻星的光压减速,完成对半人马座三星系统的探测后,再向相反的方向加速,再用几十年时间返回太阳系。听起来是个美妙的计划,但实际上只是一个根本不可能实现的梦想。」
「你又想错了,到达比邻星后中国太阳不减速,以每秒三万多公里的速度掠过它,并借助它的光压再次加速,飞向天狼星。如果有可能,我们还会继续蛙跳,飞向第三颗恒星,第四颗……」
「你到底要干什么?」庄宇失态地大叫起来。
「我们向地球所要求的,只是一套高可靠性但规模较小的生态循环系统。」

出生乡村的水娃,在几十年间便成为了第一位想要实践星际探险的冒险家。一开始我觉得,之所以他能获得如此大的加速度,是因为他不回头,但文中却描写了很多水娃回望地球的情节,他始终对家乡存在眷恋,他并不是总是一往无前的。真正造成他的改变的,可能还是他与空间站上一位工程师的对话。

有一次水娃向站里的一位工程师说出了自己的一个困惑:「人类在上世纪六十年代就登上了月球,为什么后来反而缩了回来,到现在还没登上火星,甚至连月球也不去了?」
工程师说:「人类是现实的动物,上世纪中叶那些由理想主义和信仰驱动的东西是没有长久生命力的。」
「理想和信仰不好吗?」
「不是说不好,但经济利益更好,如果从那时开始人类就不惜代价,做飞向外太空的赔本买卖,地球现在可能还在贫困之中,你我这样的普通人反而不可能进入太空,虽然只是在近地空间。朋友,别中了霍金的毒,他那套东西一般人玩不了的!」

就像炮膛射出的弹丸,飞得再高也是要掉回地面的。
除非超过第一宇宙速度。
水娃做的就是在这个最好的时代,在这个黄金还未褪去的时刻,通过最奋力的一跃,超出了引力的桎梏,因而,在也不会回到地面了,也会行到很远很远的地方。

如若绽放,便从一而终,一旦选择星辰大海,便只余星辰大海。

Posted 2024-05-13Updated 2025-05-13Notea few seconds read (About 110 words)

Matter of Life and Death

ideology != philosophy

philosophy will never judge the correctness of reality while ideology will.
关于ideology,例如苏联的连环杀人狂,在资本世界才有连环杀人于是苏联对于自己国家的杀人狂不追查,认为不存在。

ethics definition

The philosophy of relation.
Doesn’t judge anything, just describe all the interaction.(unlike morality)

deontology

There is no reason for that. The reason is simply because of being.
Dead-end for ethical argument.

consequentialism

The ends justify the means(the efforts for getting the result).

Game Principle of <JustWork>
Posted 2024-05-12Updated 2025-05-13Note2 minutes read (About 363 words)

Game Principle of <JustWork>

参考

Besiege

核心功能

机械建造

需要更高的建造自由度:例如刚体零件的顶点自定义,3轴移动,3轴旋转,3轴缩放。
可视化内容更丰富:例如碰撞箱,连接点。

物理优化

目前还是使用phsX引擎,考虑一下GPU加速这块功能。
零件之间的连接考虑使用joint以外的方式,特别是某些刚性连接。

逻辑电路体系

参考我写的BesiegeModern Mod

零件材质自定义

{金属,木,玻璃}
需要自己写shader material实现该功能。

次要功能

更好的机械破坏系统

譬如撞击变形,高速击穿之类的
很难
在已有父刚体在运行中,更改碰撞箱布置是非常耗费性能的。

场景建造

自定义场景元素

教程系统

参考mc机械动力模组的“思索”
animation制作

故事模式

起部分教程作用,添加沉浸感,吸引一些非硬核玩家

三渲二

难,可能对电脑性能有较高要求。

目前需要的技术栈

unity shader
unity animation
美术相关工具
物理引擎Game Physics Engine Development
unity URP

Posted 2024-05-12Updated 2025-05-13Note4 minutes read (About 537 words)

如果哪天有幸接触乐器的话,一定要弹弹下面的曲子呀

Goal

  • 人生的旋转木马(本命)
  • 残酷天使的行动纲领
  • 使一颗心免于哀伤(也使我不再哀伤)
  • 生命的名字
  • 梦中飞行(好不容易有了爱的人,却面临失去的恐惧)
  • 人生的约束
  • Take Me Home Country Roads (From <The Best of John Denver>)
  • 跨越时空的思念(泛音好仙)
  • Five Hundred Miles
  • 春日影
  • God knows
  • Call of Silence
  • 黄金之风处刑曲
  • I really want to stay at your house

Ukulele

考虑到便携易学,放寝室里也不会占太多空间,入了尤克里里(虽然貌似ysn前不久还在wb吐槽过)。300块在闲鱼收了一架单板相思木的尤克里里。
下面就暂且记录一下尤克里里的学习过程吧。

基础

教程:https://www.bilibili.com/video/BV1st411q7yc/?spm_id_from=333.337.search-card.all.click&vd_source=45fc7197aaca220eec8fef4c2711efe3
进度:
7/18:p5

曲

使一颗心免于悲伤

https://www.bilibili.com/video/BV1d2421T7xJ/?spm_id_from=333.337.search-card.all.click&vd_source=45fc7197aaca220eec8fef4c2711efe3
进度:
7/19:11小节,前奏的速度终于可以跟上了。好好听。
7/20:17小节,后面的指弹琶音好难,横按也按不到位。
7/27:27小节,横按还是效果不好,但至少能出音了,就是不是很稳定。录了个小视频。
9/20:卡在38小节扫弦,节奏掌握不好

穿越时空的思念

泛音扫弦到底是怎么做到的。。

人生的旋转木马

easy啦

电吉他

海鲜市场在众多鲁琴中找到一把GRG220PA1 classic拾音器的电吉他,遂购入。音箱用marshell的ms2迷你音箱,方便寝室里使用,暂且不连效果器。

看到学吉他分为这么些个级别:

  • 皮毛
  • 入门
  • 吉他运动员
  • 高级吉他运动员
  • 吉他手
  • 吉他大师
  • 吉他英雄(?

我要做吉他🦸!

曲

春日影

https://www.bilibili.com/video/BV1gu41137cg/?spm_id_from=333.337.search-card.all.click&vd_source=45fc7197aaca220eec8fef4c2711efe3

God Knows

《地下室手记》读书会p4
Posted 2024-05-11Updated 2025-05-13读读噜3 minutes read (About 465 words)

《地下室手记》读书会p4

我看这本书是抱着,我希望陀子能够帮我剖析我自己,希望他能够指出我内心不曾察觉的阴暗角落。
但说实话感觉有些失望以及作呕,大概是唯一一本“想赶着马上读完以脱离阅读带来的折磨”的书。

本书开篇即表明主人公自己是有病的,是心怀歹毒。但是他所作的剖析更多时候让我感觉像是纯粹为了贬损,好似只有贬损才是唯一客观的剖析。当自夸一些优异特质时,貌似是永远无法抵达自我本质的。
当我在谈论我自己做模组时,其实我是想在“背离世俗的评价标准的倾向(说白了就是反卷)”和“展现自己的专业能力(说白了就是装逼,自我价值的实现)”两者之间找到的平衡。我承认无偿制作分享模组是一件带有“美与崇高”的事情,但是如果它无法达成前面这种平衡,那我就不会选择它。也就是说我并非出于美与崇高(要求人们尊重我)去选择它,我只是在少数可选项中选择了相对更加美与崇高的一项。在这里,自由确实是我的第一性,自由超过了美与崇高,也超过了理性。

其实我感觉我在前面记的一些博客中的自我剖析已经非常接近陀子对于主人公的剖析了,也难怪读来让人窒息。看着这本书里的独白,说实话我感到熟悉而恶心。

鹭岛旅
Posted 2024-05-07Updated 2025-03-09杂记23 minutes read (About 3473 words)

鹭岛旅

很久很久去外省市旅行过了。
疫情前,因为工作性质的原因,虽然父母无需打卡上班,看似自由支配的时间很多,但实际上也意味着不会有明确的长假安排,家里出去基本也以一日游居多。记忆里上一次出去是初中去杭州。疫情后老妈子总是担心出去要得病,而且要求我们也非必要不出游。
我从小也对于旅游不感冒,非常傲慢地认为,旅游不就是花很多钱,在难得的空闲时间里,挤到人最多的地方,然后看几个也没啥好看的景点,然后带着一身疲惫去读书吗?那时候我还不理解旅行和旅游的区别。
说来小时候出去玩印象最深的其实是行的过程。去西湖印象最深的是和麻麻骑双人自行车绕湖骑了一圈。去北京印象最深的是爬了好久长城,到顶之后还一股脑滚下来过。
慢慢长大,我在高三暑假那年明确跟家里人说我要去骑行,而且要骑个远的,要到拉萨。当时可把他们吓得够呛呀。后来因为综评等一系列事情,发现时间凑不出来,我也就作罢,宅了一个暑假。大概是这个时候,我对于出去玩这件事情的认识,第一次从旅游变成了旅行。即,出去玩不是为了游乐,为了到特定的地区场所,高效汲取同质化的快乐,而是为了行万里路,在行的过程中认识人,认识路,认识自己。我认为禅宗之意是旅途中不可分离的一部分。走马观花而心不明净,是为游而非行。行者无疆,旅行带来的便该是这种开阔,自信,昂扬。
到大二,和航模队的大家去阜新参加比赛。第一次乘绿皮,还在绿皮上学会了斗地主。绿皮上,hmt和我说,下次工训的比赛,我们一起;crz跟我说一起创立一个club。
然后便是目前处于大四春假的时候了。老爸几年前就开始嚷嚷着要去厦门玩了,但因为种种原因一直没去,我感觉他都快忘了。我提出,失恋了好痛苦呀,网上说必须要看海!老妈子自然是担心我一个人去会出事(比如找个风水好的地把自己埋了),所以就让老爸一起,完美!!

Read more
Posted 2024-04-25Updated 2025-05-13Notea minute read (About 219 words)

Graduate Project

拟题:
基于混合现实的智能体交互

具体功能:
通过hololens2获取场景数据(识别小车/其他物体的位置,网格信息)。
通过hololens2的立体空间交互能力,指挥小车进行移动,执行任务(譬如抓取柱体并移动到相应位置)。

  • 关于移动,可以是在眼镜中通过手部动作画一条路径
  • 关于执行任务,可以是眼镜识别出物体的位置后规划小车移动和动作序列(A*or强化学习)->相关信息发给小车->小车收到后执行
    通过hololens2的虚拟物体放置功能,譬如可以放置小车的车库,柱体移动到的目标位置等
    可以通过hololens2显示小车将要移动的意图
Previous
Next
  • 1
  • …
  • 16
  • 17
  • 18
  • 19
  • 20
  • …
  • 27
Chen Yulin

Chen Yulin

SJTU student

Manchester by the Sea

Posts

261

Categories

8

Tags

187

Follow

Archives

  • May 20257
  • April 202517
  • March 202545
  • February 202512
  • January 202513
  • December 202412
  • November 20244
  • October 202418
  • September 202417
  • August 202413
  • July 20243
  • June 20245
  • May 202413
  • April 202417
  • March 20241
  • January 20241
  • December 20231
  • May 202346
  • August 20221
  • May 20226
  • April 20229

Recents

Matlab on Archlinux

2025-05-13

Matlab on Archlinux

Note

2025-05-13

Part-level Dataset Available for Augmentation

Note

Feature Pyramid Networks for Object Detection

2025-05-08

Feature Pyramid Networks for Object Detection

Review

Write Latex in Neovim on Archlinux

2025-05-07

Write Latex in Neovim on Archlinux

Note

Davinci-resolve on Archlinux

2025-05-07

Davinci-resolve on Archlinux

Note

Tags

3D-Scene4
6-D3
AI10
AIGC1
AR2
Academic1
Algorithm1
Aliyun1
App2
Atlas1
BS41
Beautify1
Behaviorism1
Business1
C1
CADC1
CD1
CLIP5
CNN1
CV28
Capstone10
Communication2
Contrastive-Learning3
Control2
Csharp9
Css1
Cuda3
DD1
DINO4
DT1
Dataframe1
Debate5
Debugger1
Diffusion1
Discrete-Mathematics1
Docker1
Docs2
Dynamic-programming1
ESP322
Education1
Embeded-System9
Embodied-AI8
Emoation1
Emotion12
Ethic1
FL1
FPN2
Family1
Federated-Learning1
Foundation1
Functional programming1
GPT3
Game5
Gated-NN2
Git7
Github1
Godot3
HPC1
HRI2
Haskell1
Health2
Hexo10
Hierarchical1
Html5
Humanism1
Hyprland2
IK1
Image-Grounding1
Image-Text5
Image-generation1
ImitationLearning3
Jolt1
Json1
LLM12
LSP2
Latex2
Life4
LinearAlgebra1
Linux21
Live2d1
Love3
Lua1
MBTI1
ML5
MR/AR3
Mason1
Math3
Meme1
Message-Passing1
Mod3
Motivation1
Movie1
Multi-modal6
Multi-view1
Music5
NLP4
NN4
Network2
Nodejs5
Numpy1
Nvim9
Object-Detection4
Open-Vocabulary9
OpenCV1
Oral1
PHD1
PSY5
Pandas2
Panoptic1
Path1
Philosophy3
PhysX1
Physical-Scene4
Physics-engine1
Pio2
Planning1
Plugin8
PoseEstimation3
Postgraduate1
Prefab1
Probability1
Python26
Pytorch1
QML1
Quantum1
RNN4
ROS3
Reading19
Real2Sim1
Reconstruct9
Regex2
Reinforcement-learning1
Repository5
Representation-Learning1
Research-paper86
Robot1
Robotics16
SJTU-Lecture1
SQL2
SSH2
Scene-graph29
Scene-synthesis1
Science-fiction1
Scrap1
Script2
Segmentation7
Semantic12
Shader3
Shell4
Signals and Systems1
Sim2Real1
Sklearn1
Snippets1
Society4
Star-rail1
Subgraph1
Submodule1
Supervised-learning2
Survey3
TC1
TOEFL1
Task-Planning6
Tasks4
Tech Communication1
Torch4
Transformer11
Translation-Embedding2
Travel2
Unity20
Unsupervised-learning1
VLM5
VLP2
Version-management1
ViT4
VideoEditing2
Vim1
Visual-Relation20
WSL1
Waybar1
Wayland1
Web1
Website1
Well-being1
Window-manager2
YKLL3
Zen2
🐱1
Chen Yulin's BlogChen Yulin's Blog

© 2025 Chen Yulin  Powered by Hexo & Icarus

×