Kaynağa Gözat

烧录错误,我说怎么设备树已经编译了,但是linux内核还是老版本,这里烧录错误文件了,应该烧录boot.img

xuxinyi 1 yıl önce
ebeveyn
işleme
5ace47998f

+ 0 - 12
固件/parameter.txt

@@ -1,12 +0,0 @@
-FIRMWARE_VER: 1.0
-MACHINE_MODEL: RK3568
-MACHINE_ID: 007
-MANUFACTURER: RK3568
-MAGIC: 0x5041524B
-ATAG: 0x00200800
-MACHINE: 0xffffffff
-CHECK_MASK: 0x80
-PWR_HLD: 0,0,A,0,1
-TYPE: GPT
-CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00020000@0x00028000(recovery),0x00010000@0x00048000(backup),0x00c00000@0x00058000(rootfs),0x00040000@0x00c58000(oem),-@0x00c98000(userdata:grow)
-uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9

BIN
固件/uboot.img


BIN
固件/update.img


BIN
开发笔记/img_2.png


BIN
开发笔记/img_3.png


BIN
开发笔记/img_4.png


BIN
开发笔记/img_5.png


+ 6 - 6
开发笔记/开发笔记.md

@@ -101,15 +101,15 @@
     ./build.sh kernel
     如果出现下面的这一行,说明编译成功。否则驱动有错误,请检查
     ![img_1.png](img_1.png)
-18.烧录(单独烧录,适用于只编译linux kerenl(如wsl环境))
+18.烧录(单独烧录,适用于只编译linux kerenl(如wsl环境))(注意:烧录的是boot.img,不是uboot.img,吃了很多亏)
     第12步,已经生成update.img
-    同时也生成了uboot.img
-    ![img_2.png](img_2.png)
+    同时也生成了boot.img
+    ![img_5.png](img_5.png)
     将这个文件复制出来。
-    按图所示,勾选这一栏,并选择你刚刚复制出来的uboot.img
-    ![img_3.png](img_3.png)
+    按图所示,勾选这一栏,并选择你刚刚复制出来的boot.img
+    ![img_2.png](img_2.png)
     如果烧录过update.img。会进入adb模式。
     长按复位按钮,同事点按boot按钮,会进入loard模式。
-    ![img_4.png](img_4.png)
+    ![img_3.png](img_3.png)
     这样就可以烧录了。
     由于我们的驱动目前还没有绑定设备树,也没编写自动注册驱动程序。所以,目前需要手动注册。但是手动注册不是我们目的,后续直接用设备树进行注册。

+ 3 - 4
设备树/tspi-rk3566-user-v10-linux.dts

@@ -56,10 +56,9 @@
 		pinctrl-0 = <&hp_det>;
 	};
 
-	mynode{
-		model="fsl,mpc8572ds"
-		compatible="fsl,mpc8572ds"
-	};
+    mynode4 {
+
+    };
 
 	leds: leds {
 		compatible = "gpio-leds";

+ 121 - 8
驱动文件/1/leds-user-defind.c

@@ -1,14 +1,127 @@
 #include <linux/module.h>
 #include <linux/init.h>
-static int __init helloworld_init(void) {
- pr_info("Hello world initialization!\n");
- return 0;
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/timer.h>
+
+struct my_device_data {
+    struct timer_list my_timer;
+    struct platform_device *pdev;  // 添加指向 platform_device 的指针
+};
+
+void my_timer_callback(struct timer_list *t) {
+    struct my_device_data *data = from_timer(data, t, my_timer);
+    dev_info(&data->pdev->dev, "hello world\n");  // 通过指针访问设备
+
+    // 重新启动定时器
+    mod_timer(&data->my_timer, jiffies + msecs_to_jiffies(10000));
 }
-static void __exit helloworld_exit(void) {
- pr_info("Hello world exit\n");
+
+static int my_device_probe(struct platform_device *pdev) {
+    struct my_device_data *data;
+    struct device_node *np = pdev->dev.of_node;
+
+    // 分配设备数据结构
+    data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+    if (!data)
+        return -ENOMEM;
+
+    // 存储 platform_device 指针
+    data->pdev = pdev;
+
+    // 初始化定时器
+    timer_setup(&data->my_timer, my_timer_callback, 0);
+
+    // 启动定时器
+    mod_timer(&data->my_timer, jiffies + msecs_to_jiffies(10000));
+
+    // 存储设备数据指针
+    platform_set_drvdata(pdev, data);
+
+    dev_info(&pdev->dev, "设备匹配: %s\n", np->name);
+
+    return 0;
 }
-module_init(helloworld_init);
-module_exit(helloworld_exit);
+
+static int my_device_remove(struct platform_device *pdev) {
+    struct my_device_data *data = platform_get_drvdata(pdev);
+
+    // 删除定时器
+    del_timer_sync(&data->my_timer);
+
+    dev_info(&pdev->dev, "设备移除\n");
+    return 0;
+}
+
+static const struct of_device_id my_device_ids[] = {
+    { .compatible = "mynode", },
+    { /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, my_device_ids);
+
+static struct platform_driver my_device_driver = {
+    .probe = my_device_probe,
+    .remove = my_device_remove,
+    .driver = {
+        .name = "my_device_driver",
+        .of_match_table = my_device_ids,
+        .owner = THIS_MODULE,
+    },
+};
+
+module_platform_driver(my_device_driver);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("John Madieu <john.madieu@gmail.com>");
-MODULE_DESCRIPTION("Linux kernel module skeleton");
+MODULE_DESCRIPTION("示例设备树驱动,每10秒打印一次hello world");
+
+
+private fun addAndUploadPhoto(path: String, context: Context, activity: Activity, ok: (String) -> Unit) {
+    "addAndUploadPhoto path:${path}".logDebug()
+    uploadTag = path
+
+    val file = File(path)
+    val requestBody = RequestBody.create(MediaType.parse("image/*"), file)
+    val body = MultipartBody.Part.createFormData("file", file.name, requestBody)
+
+    val client = OkHttpClient()
+    val url = "https://your-api-endpoint/admin/sys-file/upload"
+
+    val request = Request.Builder()
+        .url(url)
+        .post(body)
+        .build()
+
+    client.newCall(request).enqueue(object : Callback {
+        override fun onFailure(call: Call, e: IOException) {
+            activity.runOnUiThread {
+                "图片上传失败".toastShort()
+                mLoadingDialog?.dismiss()
+                mLoadingDialog = null
+            }
+        }
+
+        override fun onResponse(call: Call, response: Response) {
+            if (response.isSuccessful) {
+                val responseBody = response.body()?.string()
+                val jsonObject = JSONObject(responseBody)
+                val filePath = jsonObject.getString("filePath")
+
+                activity.runOnUiThread {
+                    "https://your-api-endpoint/$filePath".logDebug()
+                    ok.invoke("https://your-api-endpoint/$filePath")
+                    "上传成功".toastShort()
+                    mLoadingDialog?.dismiss()
+                    mLoadingDialog = null
+                }
+            } else {
+                activity.runOnUiThread {
+                    "图片上传失败".toastShort()
+                    mLoadingDialog?.dismiss()
+                    mLoadingDialog = null
+                }
+            }
+        }
+    })
+}