msp430: memset and memcpy in core don't write anything, so globals aren't initialized
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 75/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- zig
- 领域
- embedded-iot
调研方向
阅读core/src/cpus/msp430.zig中memset和memcpy的实现,然后使用提供的MSP430模拟器命令和examples/texasinstruments/msp430/src/empty.zig设置重现启动行为。修复循环比较和控制流,使.bss被清零且.data被复制;确认内存转储在0x200处显示34 12,在0x204处显示00 00。
由索引模型根据 Issue 内容生成。
描述
memset and memcpy in core/src/cpus/msp430.zig return without writing anything. The startup code (initialize_system_memories) uses them to clear .bss and copy .data, so on MSP430 global variables start with whatever is in RAM. This affects both boards (msp430x.zig uses the same functions).
Both loops compare a register with itself, because MOV is src, dst:
memset:MOV R12, R5andADD R5, R14leave the end in R14, but the loop doesCMP R5, R12(start against start), so it exits right away.memcpy:MOV R5, R12overwrites the destination with R5, soCMP R5, R12also exits right away. It also has noJMP memcpy_loop, andSUB R12, R14changes R14 instead of restoring R12.
Reproduce on 8862a281 with Zig 0.17.0, in the mspdebug simulator (I don't have MSP430 hardware). Replace examples/texasinstruments/msp430/src/empty.zig with:
const std = @import("std");
const microzig = @import("microzig");
pub const std_options = microzig.std_options(.{});
comptime {
_ = microzig.export_startup();
}
pub const panic = std.debug.no_panic;
var initialized: u16 = 0x1234; // .data
var zeroed: u16 = 0; // .bss
pub fn main() void {
std.mem.doNotOptimizeAway(&initialized);
std.mem.doNotOptimizeAway(&zeroed);
}
cd examples/texasinstruments/msp430
zig build -Doptimize=ReleaseSmall
# initialized is at 0x200 and zeroed at 0x204; 0xc02a is microzig_main
mspdebug -q sim "prog zig-out/firmware/empty_MSP430G2553.elf" "fill 0x200 16 0xaa" "reset" "setbreak 0xc02a" "run" "md 0x200 8"
Result:
00200: aa aa aa aa aa aa aa aa
Expected 34 12 at 0x200 and 00 00 at 0x204. With both loops fixed (end in R14, compare the cursor against it, jump back), the same program gives:
00200: 34 12 00 00 00 00 00 00
I can open a PR with the fix if you want.
- 主要语言
- Zig
- 星标
- 2.3k
- 派生
- 198
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ZigEmbeddedGroup/microzig 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
ZigEmbeddedGroup/microzig#1086 ·
维护者通常 1 天内回复
-
drivers: `I2C_Device.Address.check_reserved` rejects 0x08-0x0F and accepts 0x04-0x07 (HighSpeedMaster range is off by one bit)可能已有人在做 @SAY-5 于 2 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 69/100
ZigEmbeddedGroup/microzig#1085 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1061 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1059 · 1 条评论 ·
维护者通常 1 天内回复
-
AVR (ATmega328P): UART/SPI HAL, drivers.zig, and nRF24L01+ driver (Emakefun RF-Nano V3.0)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 35/100
ZigEmbeddedGroup/microzig#1069 · 3 条评论 ·
维护者通常 1 天内回复
查看 ZigEmbeddedGroup/microzig 的全部 Issue
相似的 Issue
-
AP_GPS: NMEA values between -1 and 0 lose their sign (GGA altitude -0.5 m reads +0.5 m)可能已有人在做 @shubhamrai9122-creator 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
siderolabs/talos#14728 ·
维护者通常 1 天内回复
-
Component:RTL Status:New Type:Bug
难度 2/5 1-3 小时 新手友好度 82/100
openhwfoundation/cva6#3673 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
justcallmekoko/ESP32Marauder#1664 ·
维护者通常 1 天内回复
-
[BUG] S7: no tag is read on S7-300 CPUs (PDU 240) with more than 19 non-DB tags (follow-up of #694)未关闭
难度 2/5 1-3 小时 新手友好度 78/100
frangoteam/FUXA#2651 ·
维护者通常 5 天内回复