AVR内存和intel十六进制(AVR memory and intel hex)
我为我的大学项目工作了一个简单的AVR程序员,并且我一直在理解如何将内存从十六进制文件映射到实际的闪存。
例如,intel hex为我们提供了有关数据块起始地址,其中的字节数和数据本身的信息。 麻烦来自于AVR MCU,特别是ATmega16,通常有两个字节的地址:高和低。
起初,我写了一个简单的函数,它只是读取hex文件中的所有数据并按顺序写入,每传递两个字节就增加一个地址。 令我惊讶的是它在简单的闪烁代码上工作。 但是,我不确定,如果这种方法可行,如果有人需要复杂的内存结构。
所以问题是:
- 此解决方案是否可以用于复杂的内存结构?
- 如果没有,我怎样才能将intel十六进制地址映射到实际的flash地址? 问题是在intel hex格式中没有高和低字节,只有地址=字节。
I work on a simple AVR programmer for my university project, and I am stuck with understanding how I can map memory from hex file to actual flash memory.
For instance, intel hex provides us the information about start address of data block, number of bytes in it and data itself. The trouble comes from that AVR MCUs, in particular ATmega16, often have one address for two bytes: high and low.
At first, I wrote a straightforward function, that just reads all the data from hex file and write it sequentially, increasing address by one each two bytes passed. To my surprise it works on simple blinky code. However, I am not sure, if this approach would work, if someone needs complex memory structure.
So the questions are:
- Will this solution work on complex memory structures?
- If not, how can I map intel hex address into actual flash address? The problem is there is no high and low bytes in intel hex format, only address = byte.
原文:https://stackoverflow.com/questions/42030245
最满意答案
withReader
块隐式返回闭包的最后一行,在您的情况下是:println "YamlTapeLoader : inside readFrom : "+reader
并且
println
返回null
,因此将代码更改为:def tape = file.withReader(FILE_CHARSET) { reader -> def ret = YamlTape.readFrom(reader) println "YamlTapeLoader : inside readFrom : "+reader ret // Return the result of YamlTape.readFrom }
它应该工作
编辑
您的
readFrom
方法具有相同的错误...将其更改为:static YamlTape readFrom(Reader reader) { try { println "YamlTape : inside readFrom reader.size() = "+reader+" YamlTape: "+YamlTape def ret = Yaml.loadAs(reader, YamlTape) println "YamlTape : after readfrom" ret // Return the YamlTape } catch (YAMLException e) { println "YamlTape : inside catch block" throw new TapeLoadException('Invalid tape', e) } }
The
withReader
block implicitly returns the last line of the closure, which in your case is:println "YamlTapeLoader : inside readFrom : "+reader
And
println
returnsnull
, so change the code to:def tape = file.withReader(FILE_CHARSET) { reader -> def ret = YamlTape.readFrom(reader) println "YamlTapeLoader : inside readFrom : "+reader ret // Return the result of YamlTape.readFrom }
And it should work
Edit
Your
readFrom
method has the same error... Change it to:static YamlTape readFrom(Reader reader) { try { println "YamlTape : inside readFrom reader.size() = "+reader+" YamlTape: "+YamlTape def ret = Yaml.loadAs(reader, YamlTape) println "YamlTape : after readfrom" ret // Return the YamlTape } catch (YAMLException e) { println "YamlTape : inside catch block" throw new TapeLoadException('Invalid tape', e) } }
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如何在Python中使用ruamel.yaml从YAML文件中获取注释?(How can I get comments from a YAML file using ruamel.yaml in Python?)[2022-04-02]
图书馆作者在BitBucket上发表了一篇关于此的评论(2016年5月9日): 评论保存尚未稳定,例如,如果映射的键和值不在同一行并且键(或键和值)都有注释,我需要做一些事情。 我最初的目标是保留现有的评论,而不是操纵。 通过一些实验,我确定了上面问题中提供的示例代码的以下工作: print('Comment 1: ' + loaded.ca.comment[1][0].value) print('Comment 2: ' + loaded.ca.items['a'][2].value) print('Co ... -
当我运行你的代码时,它会输出: java.util.LinkedHashMap@6500df86[ accessOrder=false threshold=12 loadFactor=0.75 ] 这是Map对象的字符串表示形式,而不是内部的字符串表示形式。 困难的方式: 如果你想使用ReflectionToStringBuilder ,恐怕你必须通过扩展ToStringStyle来实现自己的风格。 你的风格必须通过Map并提取键和值。 简单的方法: 但是,你可以用简单的循环实现你想要的东西 ...
-
您可以从Config.groovy导入外部配置文件。 Config.groovy中已经注释掉了代码,说明了如何执行此操作: grails.config.locations = [ "classpath:${appName}-config.properties", "classpath:${appName}-config.groovy"] 假设您的应用程序名称为foo,您现在可以在类路径的某处放置foo-config.groovy或foo-config.pr ...
-
在Groovy中读取YAML文件(Read a YAML file in Groovy)[2023-06-15]
withReader块隐式返回闭包的最后一行,在您的情况下是: println "YamlTapeLoader : inside readFrom : "+reader 并且println返回null ,因此将代码更改为: def tape = file.withReader(FILE_CHARSET) { reader -> def ret = YamlTape.readFrom(reader) println "YamlTapeLoader : ... -
如果您绝对想要使用此文件设计,请使用YAML::load_documents加载多个记录。 我建议改为使用文件中的列表。 对我来说似乎更干净(因为你拥有的是类似记录的列表,而不是一组不相关的文档)。 If you absolutely want to go with this file design, then use YAML::load_documents to load more than one record at a time. I would suggest instead using an l ...
-
js-yaml的确如此。 我通过谷歌搜索“node js yaml”发现了这一点,因为从JavaScript中的文件读取服务器端与node.js(或类似的东西)完成,而不是从浏览器完成。 js-yaml的README开始 用法:js-yaml [-h] [-v] [-c] [-j] [-t]文件 位置参数: 档案与YAML文件(s) 这是非常有力的证据,它直接从文件处理YAML。 js-yaml does. I found this by Googling "node js yaml" because re ...
-
使用C脚本读取YAML文件(Read a YAML file using a C script)[2024-01-10]
这个问题的第二个答案有一个更好的例子,使用该库将yaml文件解析为更有用的东西。 The second answer to this question has a little bit better example of using the library to parse yaml file into something more useful. -
Fabric中的YAML文件(YAML file in Fabric)[2023-07-31]
Tav的博客是Fabric的自定义分支,没有被引入Mainline。 它目前也已经过时了。 你设置这些的方式是使用fabricrc文件。 这里有人谈到: http://docs.fabfile.org/en/1.7/usage/fab.html?highlight=fabricrc#settings-files 和这里 http://docs.fabfile.org/en/1.7/usage/fabfiles.html?highlight=fabricrc Tav's blog is a custom fo ... -
使用javascript加载yaml文件并获取yaml文件中的数据(Load yaml file using javascript and get the data in the yaml file)[2022-11-19]
将$ .get()数据类型参数设置为text。 jsyaml需要加载yml类型的文本数据。 Set the $.get() datatype parameter to be text. jsyaml needs yml type text data to load.