Skip to content

RT-Thread编程陷阱与防坑指南清单 #3912

Description

@geniusgogo

此issue登记记录在开发过程中遇到的一些使用陷阱,并最好能提供如何规避此类陷阱的方法、思路以及故事:)

  • rt_malloc/rt_free
  • 内核版本:<4.0.3
  • 陷阱1:不应该出现在中断上下文中
  • 说明:由于rt_malloc/rt_free里会操作锁,RT-Thread在中断上下文中不可拿锁。
  • 陷阱2:不应该在关调度器、关中断后使用
  • 说明:锁有可能被其它任务占用,此时关了调度器或者中断后,本任务就可能拿锁失败,锁死系统

Activity

  1. pinned this issue on Sep 14, 2020
  2. mysterywolf commented on Apr 25, 2021

    @mysterywolf
    Member

    双精度浮点问题

    部分STM32高级芯片具备双精度浮点计算能力,设置方式有所区别,参见:
    https://club.rt-thread.org/ask/question/430612.html
    #4186 -> #4188
    RT-Thread-Studio/sdk-bsp-stm32h750-realthread-artpi#177 -> RT-Thread-Studio/sdk-bsp-stm32h750-realthread-artpi#195

  3. mysterywolf commented on Jul 2, 2021

    @mysterywolf
    Member

    慎用RT_IPC_FLAG_FIFO

    除非你有明确理由,非常关心内核对象等待队列排列顺序的先来后到,否则强烈建议用RT_IPC_FLAG_PRIO

  4. haodongnj commented on Nov 24, 2021

    @haodongnj

    STM32 CAN Bus 的比特率

    STM32的CAN驱动里面代码适配时,有预设的总线时钟。需要核查驱动预设的时钟和你使用的板子的总线时钟是否匹配。如果不匹配,则需要自行修改驱动里面的时钟配置选项,否则CAN总线的bitrate会不合预期。

  5. enkiller commented on Feb 22, 2022

    @enkiller
    Contributor

    scons Windows 平台编译,命令行参数超过 32K 报错规避办法

    1. 打开工程目录下 SConstruct 文件:

    2. 在 objs = PrepareBuilding(env, RTT_ROOT) 这一行前面添加如下代码

    def ourspawn(sh, escape, cmd, args, e):
        newargs = ' '.join(args[1:])
        cmdline = cmd + " " + newargs
        if (len(cmdline) > 16 * 1024):
            f = open('cmd.param', 'w')
            f.write(' '.join(args[1:]).replace('\\', '/'))
            f.close()
            # exec
            cmdline = cmd + " @cmd.param"
        proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
            stderr=subprocess.PIPE, shell = False, env = e)
        data, err = proc.communicate()
        rv = proc.wait()
        if rv != 0:
            sys.stderr.write(err)
        else:
            sys.stdout.write(data)
        return rv
    
    if platform.system() == 'Windows':
        env['SPAWN'] = ourspawn
    1. 在文件头部导入相应的模块
    import subprocess
    import platform
  6. supperthomas commented on May 18, 2022

    @supperthomas
    Member
  7. locked and limited conversation to collaborators on Aug 4, 2022
  8. converted this issue into a discussion #6225 on Aug 4, 2022
  9. unpinned this issue on Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions