SystemView 应用笔记

一 .什么是Systemview?

SystemView 是一个可以在线调试嵌入式系统的工具,它可以分析有哪些中断、任务执行了,以及这些中断、任务执行的先后关系。还可以查看一些内核对象持有和释放的时间点,比如信号量、互斥量、事件、消息队列等。这在开发和处理具有多个线程和事件的复杂系统时尤其有效。

说白了就是我们可以通过这个软件实时监控我们实时系统的任务切换及调度情况,并且这个软件支持多种实时系统,包括RT-thread FreeRTOS uSCIII等。

 

二.怎么将他应用到freeRTOS实时系统上

想用到RT-thread上可以参考RT-thread文档中心

https://www.rt-thread.org/document/site/application-note/debug/systemview/an0009-systemview/#

刚开始弄这东西的时候也是一头雾水,这么牛逼的软件,怎么开始用到自己的项目中呢,百度一下吧,各种文档也是看的自己迷迷糊糊。那么怎么开始用呢。

2.1肯定是下载system view这个软件呗,从哪下载,首选当然是官网。

https://www.segger.com/downloads/systemview/

目前这个软件已经更新到了v3.10,虽然这个软件是免费的但是需要配合J-link才能使用,但是正版的j-link才有授权,但是这东西很贵的,果然下载了最新版本是不能用的,查看网上有大神和谐了V2.52a,按照方法确实也破解成功了,但是该版本只能用M3的,我的板卡是M4的,不知道是不是破解的不对,最后也没有弄成功。

最后在硬汉论坛,找到了一个版本V3.07的版本

http://www.armbbs.cn/forum.php?mod=viewthread&tid=95949&fromuid=58

下载后亲测可用。

2.2当你下载完了,你就认为可以用了?这里一般还是要更新你的j-link驱动的。我开始用的J-link V8最后也没更新成功,最后还是花了100块钱买了个v9的下载器,虽然肯定没正版好用,也算是能用吧。

 

 

提示有版权问题,我直接点的continue也是能用的,不过肯定有功能限制,不过新的版本V3.10版本已经支持TCP和串口来监测了,避免了J-link的尴尬。

 

安装成功了,他会自动加载一个测试的程序。

2.3软件安装完了,就可以开心的用到自己的项目了??当然不是

他是一个监控软件,你的项目中肯定也要添加相关带来来和这个软件来配合,不过不用担心,添加代码的步骤不复杂,占用的内存也不是很多。

软件安装完之后,在他的安装路径下可以找到以下文件夹,这些就是对不同实时系统的支持文件。不同版本位置稍有差异,不过肯定都有啦。

 

2.3.1添加相关文件到你的工程中(不管你是keil还是IAR添加文件的操作就不说了)

 

\TargetSrc\Config 目录下的文件。

\TargetSrc\SEGGER 目录下的文件。

与下位机使用的操作系统相关的文件。 本人使用系统的是 FreeRTOS 9.00,用到的是这几个文件:

\TargetSrc\Sample\Config 目录下的 SEGGER_SYSVIEW_Config_FreeRTOS.c 文件。

\TargetSrc\Sample\OS 目录下的 SEGGER_SYSVIEW_FreeRTOS.c 和

SEGGER_SYSVIEW_FreeRTOS.h 文件

文件位置可能会稍有不同,文件就是这几个文件。

2.3.2修改相关配置

(1)添加头文件在main.c 中    #include "SEGGER_SYSVIEW.h"

    在系统运行之间初始化 SystemView,具体来说就是在系统运行之前增加以下语句:SEGGER_SYSVIEW_Conf();

(2)在 FreeRTOS.h 文件的头部包含 #include "SEGGER_SYSVIEW_FreeRTOS.h"

(3)在 FreeRTOSConfig.h  中添加两个宏定义

#define INCLUDE_xTaskGetIdleTaskHandle  1

#define INCLUDE_pxTaskGetStackStart     1

这样修改就基本完成了,添加过程不复杂。

 

2.4通过jlink 连接目标板    运行  system view , 左侧 三角 

如果此时在Target Device 中找不到你的片子, 重装下jlink 驱动

然后选择你的片子类型,我用的是st的STM32L476RE。

 

此时就可以对你的系统进行分析了。(可以先保存,省的软件崩掉)

三.他有什么功能

监控是成功了,但是这个通过这个软件能获得哪些信息呢?

 

这是截图别的版本的,基本都差不多。

 

在详细的内容可以查看这个人的博客

https://blog.csdn.net/bjr2016/article/details/78474154

这个软件通过使用,感觉还是非常强大的,对我们理解学习实时系统会是一个很好的工具。

 

此文档只做学习使用,如有问题可联系我进行更改。

好的,以下是一个简单的记事本App的开发过程: 1. 首先创建一个新的Android Studio项目,选择Empty Activity作为模板。 2. 在app/build.gradle文件中添加如下依赖项: ``` implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.cardview:cardview:1.0.0' ``` 这些依赖项将用于实现笔记列表的显示。 3. 在布局文件activity_main.xml中添加一个RecyclerView,用于显示笔记列表。 ``` <androidx.recyclerview.widget.RecyclerView android:id="@+id/note_list" android:layout_width="match_parent" android:layout_height="match_parent" /> ``` 4. 创建一个Note类,用于存储笔记的信息。该类应该包含笔记的标题、内容和时间戳等信息。 ``` public class Note { private String title; private String content; private long timestamp; public Note(String title, String content, long timestamp) { this.title = title; this.content = content; this.timestamp = timestamp; } public String getTitle() { return title; } public String getContent() { return content; } public long getTimestamp() { return timestamp; } } ``` 5. 创建一个NotesAdapter类,用于将笔记列表显示在RecyclerView中。该类需要继承RecyclerView.Adapter类,并实现以下三个方法: ``` public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.NotesViewHolder> { private List<Note> notes; public NotesAdapter(List<Note> notes) { this.notes = notes; } @NonNull @Override public NotesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_note, parent, false); return new NotesViewHolder(view); } @Override public void onBindViewHolder(@NonNull NotesViewHolder holder, int position) { Note note = notes.get(position); holder.title.setText(note.getTitle()); holder.content.setText(note.getContent()); holder.timestamp.setText(formatTimestamp(note.getTimestamp())); } @Override public int getItemCount() { return notes.size(); } public static class NotesViewHolder extends RecyclerView.ViewHolder { TextView title; TextView content; TextView timestamp; NotesViewHolder(View itemView) { super(itemView); title = itemView.findViewById(R.id.note_title); content = itemView.findViewById(R.id.note_content); timestamp = itemView.findViewById(R.id.note_timestamp); } } private String formatTimestamp(long timestamp) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); return sdf.format(new Date(timestamp)); } } ``` 6. 创建一个布局文件item_note.xml,用于显示每个笔记的标题、内容和时间戳。 ``` <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <TextView android:id="@+id/note_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="18sp" android:textStyle="bold" /> <TextView android:id="@+id/note_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" /> <TextView android:id="@+id/note_timestamp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:textColor="@color/colorAccent" /> </LinearLayout> </androidx.cardview.widget.CardView> ``` 7. 在MainActivity中添加以下代码,用于初始化RecyclerView笔记列表: ``` public class MainActivity extends AppCompatActivity { private RecyclerView noteList; private NotesAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); noteList = findViewById(R.id.note_list); noteList.setLayoutManager(new LinearLayoutManager(this)); List<Note> notes = new ArrayList<>(); notes.add(new Note("笔记1", "这是笔记1的内容", System.currentTimeMillis())); notes.add(new Note("笔记2", "这是笔记2的内容", System.currentTimeMillis())); notes.add(new Note("笔记3", "这是笔记3的内容", System.currentTimeMillis())); adapter = new NotesAdapter(notes); noteList.setAdapter(adapter); } } ``` 现在你已经成功地创建了一个简单的记事本App,允许用户创建、编辑和删除笔记。当用户打开App时,将显示一个笔记列表,用户可以通过点击“添加笔记”按钮来创建新的笔记,通过点击每个笔记来编辑或删除它。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值