首页 \ 问答 \ AVR内存和intel十六进制(AVR memory and intel hex)

AVR内存和intel十六进制(AVR memory and intel hex)

我为我的大学项目工作了一个简单的AVR程序员,并且我一直在理解如何将内存从十六进制文件映射到实际的闪存。

例如,intel hex为我们提供了有关数据块起始地址,其中的字节数和数据本身的信息。 麻烦来自于AVR MCU,特别是ATmega16,通常有两个字节的地址:高和低。

起初,我写了一个简单的函数,它只是读取hex文件中的所有数据并按顺序写入,每传递两个字节就增加一个地址。 令我惊讶的是它在简单的闪烁代码上工作。 但是,我不确定,如果这种方法可行,如果有人需要复杂的内存结构。

所以问题是:

  1. 此解决方案是否可以用于复杂的内存结构?
  2. 如果没有,我怎样才能将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:

  1. Will this solution work on complex memory structures?
  2. 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
更新时间:2023-02-20 12:02

最满意答案

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 returns null, 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)
  }
}

相关问答

更多
  • 图书馆作者在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 ...
  • 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 ...
  • 这个问题的第二个答案有一个更好的例子,使用该库将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.
  • 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 ...
  • 将$ .get()数据类型参数设置为text。 jsyaml需要加载yml类型的文本数据。 Set the $.get() datatype parameter to be text. jsyaml needs yml type text data to load.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)