- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 Infineon 的 XMC4500 Relax Kit,我正在尝试通过单个 GPIO 引脚提取固件。
我非常天真的想法是通过 GPIO 引脚一次转储一位,然后用逻辑分析仪以某种方式“嗅探”数据。
伪代码:
while(word by word memory copy hasn't finished)
...
register = value;
temp_value = value AND 0x1;
pin = temp_value;
value = value >> 1;
...
我走在正确的轨道上吗?有人有更好/更好的想法如何存档吗?
### 编辑###
实际上,我的(shell)代码的一个要求是它需要非常小。我找到了 this关于如何做的绝妙技巧通过闪烁 LED 转储固件。
但是,我很难通过 Saleae Logic Analyzer 接收正确的值。
基本上我正在做的是:
这是我的 C 代码:
#include "XMC4500.h"
#define DEL 1260
void init()
{
// P1.0 output, push pull
PORT1->IOCR0 = 0x80UL << 0;
// P1.1 output, push pull
PORT1->IOCR0 |= 0x80UL << 8;
}
void delay(int i) {
while(--i) {
asm("nop\n");
asm("nop\n");
}
}
// Sets a pin to high
// P1.0 = SPI MOSI
// P1.1 = SPI CLOCK
void output_high(int i) {
// P1.0 high
if(i == 0) {
PORT1->OUT |= 0x1UL;
}
// P1.1 high
if(i == 1) {
PORT1->OUT |= 0x2UL;
}
}
// Sets a pin to low
// P1.0 = SPI MOSI
// P1.1 = SPI CLOCK
void output_low(int i) {
// P1.0 low
if(i == 0) {
PORT1->OUT &= (~0x1UL);
}
// P1.1 low
if(i == 1) {
PORT1->OUT &= (~0x2UL);
}
}
// SPI bit banging
void spi_send_byte(unsigned char data)
{
int i;
// Send bits 7..0
for (i = 0; i < 8; i++)
{
// Sets P1.1 to low (serial clock)
output_low(1);
// Consider leftmost bit
// Set line high if bit is 1, low if bit is 0
if (data & 0x80)
// Sets P1.0 to high (MOSI)
output_high(0);
else
// Sets P1.0 to low (MOSI)
output_low(0);
delay(DEL);
// Sets P1.1 to high (Serial Clock)
output_high(1);
// Shift byte left so next bit will be leftmost
data <<= 1;
}
}
int main() {
init();
while(1) {
spi_send_byte('t');
spi_send_byte('e');
spi_send_byte('s');
spi_send_byte('t');
}
return 0;
}
### 第二次编辑###
使用以下代码转储闪存工作正常:
#include "XMC4500.h"
// SPI bit banging
void spi_send_word(uint32_t data)
{
int i;
// LSB first, 32 bits per transfer
for (i = 0; i < 32; i++)
{
// set pin 1.1 to low (SPI clock)
PORT1->OUT &= (~0x2UL);
// set line high if bit is 1, low if bit is 0
if (data & 0x1) {
// set pin 1.0 to high (SPI MOSI)
PORT1->OUT |= 0x1UL;
}
else {
// set pin 1.0 to low (SPI MOSI)
PORT1->OUT &= (~0x1UL);
}
// set pin 1.1 to high (SPI clock)
PORT1->OUT |= 0x2UL;
data >>= 1;
}
}
int main() {
// start dumping at memory address 0x08000000
unsigned int *p;
p = (uint32_t *)(0x08000000u);
// configure pin 1.0 and pin 1.1 as output (push-pull)
PORT1->IOCR0 = 0x8080UL;
while(1) {
spi_send_word(*p);
p++;
}
}
最佳答案
您的解决方案的最大问题是恢复时间信息 - 知道一个词从哪里开始,另一个词从哪里结束。在 UART tx 引脚上输出数据会更简单 - UART 添加起始位和停止位并为您管理时序,并且可以通过常规 PC 串行端口直接读取输出。
如果您不能使用 UART,通过使用 UART 时序对 GPIO 进行位碰撞来模拟 UART 仍然允许使用传统的串行端口直接接收数据。
可以找到软件 UART 实现示例 here .在您的情况下,您当然只需要传输能力。
关于c - 通过单个 GPIO 引脚转储闪存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23978691/
前言:这个问题是关于我正在与我的大学教授合作的一个项目。这不是为了成绩,但我在这位教授中的声誉确实很重要。因此,虽然我在这个项目上的成功对我来说很重要,但我并不认为向 Stack Overflow 寻
因此,与上一次相同的大学项目,这一次我遇到了未定义方法的麻烦。我的代码的完整性如下 package { import flash.display.MovieClip; import flash.eve
我只是想问问这是不是一个熟悉的现象。我们有一个带有文本框的小型 Flash 应用程序。 在 OSX Lion 下,flash < 10.3 .. 工作正常 使用 OSX Lion 和 Flash 10
对于某些人来说,这个问题可能很微不足道,但我不记得哪个是正确的名字对于这款闪光灯 slider ,其产品来自 here 原来的名字不是slider而是别的东西... 第二个问题:你知道像这样免费的fl
我目前正在使用 flash CS5 构建一个 iOS 应用程序,我需要一些关于几个功能的帮助: 是否可以添加应用内购买?如果是,它是如何工作的? 是否可以在应用程序中添加 iAd 广告?如果是这样,如
有没有什么简单的方法可以从 Flash IDE 中获取路径(一系列点)到 ActionScript 代码中? 例如,如果您想为要用作碰撞对象的游戏世界绘制轮廓,而现在在 AS3 中,您希望获得所绘制路
我有一个 Beagle 板 OMAP3530-GP,我已将内核和 rootfs 复制到 SD 卡的两个分区中并想启动它。 SD卡分区1:FAT32启动分区 具有相同顺序的以下文件: MLO u-boo
大学毕业后,我终于有时间回去练习我的 Flash 工作了,我需要一些帮助来让声音循环播放并根据正在播放的动画部分进行更改。 这也是我问的一个老问题的部分后续问题,所以如果你不明白,请看这里以获得更多关
我的问题是我的项目编译时间越来越长。 我的当务之急是如何加快编译速度?我现在用的是SSD硬盘和四核CPU。您认为购买 I7 核心会加快编译速度吗? 我担心它不会,因为 Flash CS5 不会利用多核
我尝试获取 mp3 flash player在所有浏览器上使用我的 javascript。一开始一切顺利,但很快意识到我的代码不适用于 MSIE。 在尝试找出后,我在引用代码中找到了这个: eva
我有 3 个问题来阐明我的 AIR 应用程序工作流程: 我在使用 Flash CS5 制作游戏时可以使用 Spark 组件吗? 当我使用 Flash Builder 时,我可以在我的 AIR for
我正在使用 YQL 尝试为我正在进行的项目查找乐队照片。如果找到图像,它会在 XML 响应中返回,然后我的 Flash 代码将其发布。但是如果没有找到,我不太确定如何告诉 Flash 不做任何事情。这
我从 Rails 3.2 升级到 4.0,现在重定向后我的 flash 消息都不起作用。 我检查过以确保我显示 Flash 消息的方式没有问题。不涉及重定向的 Flash 消息工作正常。 sessio
几个月来我一直试图解决这个问题...... 在 Flash 9 中,我尝试加载流式 MP3 文件并计算其轨道长度。我可以做到这一点,但是当 mp3 的 channel 是单声道时,时间是原始音轨长度的
我有这个代码: def create login(params[:email], params[:password]) if current_user flash[:notice] =
我正在尝试在Windows 7上使用JTAG ST-Link/V2写入STM32L476的闪存。无需上传软件,我只需将数据写入可读取和删除的非 volatile 位置。 作为一个硬件方面的新手,并且仅
当我尝试通过 fastboot system.img(从我的自定义 AOSP 构建)刷入 Sony Xperia Z3 时,出现以下错误: # fastboot flash system system
我正在内存非常受限的嵌入式 Linux 设备上通过 HTTP 将一个大文件 ( 1Gb ) 流式传输到我在 Qt 中的服务器。当我第一次收到 header 时,我确定将数据写入文件系统的何处,创建一个
我使用 Play 创建了一个 HTTP 实时流传输系统!框架和 FFMPEG。文件在不同的带宽上进行编码,并随后进行分段以传送到当前的 iOS 设备。 但是,我想扩展到网站上的嵌入式播放器(跨平台)和
我在 AS3 中有一个可用的麦克风录音脚本,我已经能够成功地使用它通过 AMF 将 .wav 文件保存到服务器。这些文件可以在任何音频播放器中正常播放,没有奇怪的效果。 作为引用,这是我为捕获麦克风的
我是一名优秀的程序员,十分优秀!