Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    D1上运行openEuler,其上运行java语言版本的helloworld的方法

    MR Series
    1
    1
    1278
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • whycan
      whycan晕哥 LV 9 last edited by whycan

      转载: https://zhuanlan.zhihu.com/p/401285641
      D1上运行openEuler,其上运行java语言版本的helloworld的方法

      1. 烧录openEuler镜像到TF并对TF扩容

      参考文档:
      D1上的OpenEuler烧录安装及根目录扩容

      在ubuntu20.04下,执行sudo fdisk -l查看TF卡盘符

      jean@jean-virtual-machine:/mnt/hgfs/linux$ sudo fdisk -l
      Disk /dev/sdb: 29.74 GiB, 31914983424 bytes, 62333952 sectors
      Disk model: Storage Device  
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: gpt
      Disk identifier: EACEFD8D-68B3-493F-868A-5364E0A693D8
      ​
      Device      Start      End  Sectors  Size Type
      /dev/sdb1   34784    35039      256  128K Linux filesystem
      /dev/sdb2   35040    35295      256  128K Linux filesystem
      /dev/sdb3   35296   100831    65536   32M Linux filesystem
      /dev/sdb4  102400 62333918 62231519 29.7G Linux filesystem
      

      使用dd命令将openEuler镜像烧录到TF卡中

      jean@jean-virtual-machine:/mnt/hgfs/linux$ bzcat openEuler-D1-wifi-hdmi-20210817.img.bz2 | sudo dd of=/dev/sdb bs=1M iflag=fullblock oflag=direct conv=fsync status=progress
      1341128704 bytes (1.3 GB, 1.2 GiB) copied, 176 s, 7.6 MB/s 
      1279+0 records in
      1279+0 records out
      1341128704 bytes (1.3 GB, 1.2 GiB) copied, 176.061 s, 7.6 MB/s
      

      执行sudo fdisk -l查看TF卡分区

      jean@jean-virtual-machine:/mnt/hgfs/linux$ sudo fdisk -l
      Disk /dev/sdb: 29.74 GiB, 31914983424 bytes, 62333952 sectors
      Disk model: Storage Device  
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: gpt
      Disk identifier: EACEFD8D-68B3-493F-868A-5364E0A693D8
      ​
      Device      Start     End Sectors  Size Type
      /dev/sdb1   34784   35039     256  128K Linux filesystem
      /dev/sdb2   35040   35295     256  128K Linux filesystem
      /dev/sdb3   35296  100831   65536   32M Linux filesystem
      /dev/sdb4  100832 2619391 2518560  1.2G Linux filesystem
      

      执行sudo fdisk /dev/sdb,对TF卡中的最后一个分区进行扩容

      jean@jean-virtual-machine:/mnt/hgfs/linux$ sudo fdisk /dev/sdb
      ​
      Welcome to fdisk (util-linux 2.34).
      Changes will remain in memory only, until you decide to write them.
      Be careful before using the write command.
      ​
      A hybrid GPT was detected. You have to sync the hybrid MBR manually (expert command 'M').
      ​
      Command (m for help): p #查看并记录第四个分区的起始扇区
      ​
      Disk /dev/sdb: 29.74 GiB, 31914983424 bytes, 62333952 sectors
      Disk model: Storage Device  
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: gpt
      Disk identifier: EACEFD8D-68B3-493F-868A-5364E0A693D8
      ​
      Device      Start     End Sectors  Size Type
      /dev/sdb1   34784   35039     256  128K Linux filesystem
      /dev/sdb2   35040   35295     256  128K Linux filesystem
      /dev/sdb3   35296  100831   65536   32M Linux filesystem
      /dev/sdb4  100832 2619391 2518560  1.2G Linux filesystem
      ​
      Command (m for help): d #删除分区
      Partition number (1-4, default 4): 4
      ​
      Partition 4 has been deleted.
      ​
      Command (m for help): n #新建分区
      Partition number (4-128, default 4): 4
      First sector (100832-62333918, default 102400): 100832 #和最开始记录的第四个分区的起始扇区相同
      Last sector, +/-sectors or +/-size{K,M,G,T,P} (100832-62333918, default 62333918): 
      ​
      Created a new partition 4 of type 'Linux filesystem' and of size 29.7 GiB.
      Partition #4 contains a ext4 signature.
      ​
      Do you want to remove the signature? [Y]es/[N]o: n
      ​
      Command (m for help): w #写入修改
      The device contains hybrid MBR -- writing GPT only. You have to sync the MBR manually.
      ​
      The partition table has been altered.
      Failed to update system information about partition 4: Invalid argument
      ​
      The kernel still uses the old partitions. The new table will be used at the next reboot. 
      Syncing disks.
      

      对最后一个分区执行resize2fs命令

      jean@jean-virtual-machine:/mnt/hgfs/linux$ sudo resize2fs /dev/sdb4
      resize2fs 1.45.5 (07-Jan-2020)
      Filesystem at /dev/sdb4 is mounted on /media/jean/rootfs; on-line resizing required
      old_desc_blocks = 5, new_desc_blocks = 119
      The filesystem on /dev/sdb4 is now 31116540 (1k) blocks long.
      

      查看扩容后的TF卡分区

      jean@jean-virtual-machine:/mnt/hgfs/linux$ sudo fdisk -l
      Disk /dev/sdb: 29.74 GiB, 31914983424 bytes, 62333952 sectors
      Disk model: Storage Device  
      Units: sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disklabel type: gpt
      Disk identifier: EACEFD8D-68B3-493F-868A-5364E0A693D8
      ​
      Device      Start      End  Sectors  Size Type
      /dev/sdb1   34784    35039      256  128K Linux filesystem
      /dev/sdb2   35040    35295      256  128K Linux filesystem
      /dev/sdb3   35296   100831    65536   32M Linux filesystem
      /dev/sdb4  100832 62333918 62233087 29.7G Linux filesystem
      

      到这里烧录openEuler并扩容TF卡就结束了

      2. 安装java环境并运行hello world脚本
      将上述烧录好的TF卡插入D1并启动D1, 用Xshell通过serial的方式连接D1,登录openEuler,用户名/密码:root/openEuler12#$

      Connecting to COM3...
      Connected.
      ​
      openEuler-RISCV-rare login: root
      Password: 
      Last login: Thu Aug 19 02:37:06 on ttyS0
      ​
      ​
      Welcome to 5.4.61
      ​
      System information as of time:  Thu Aug 19 02:38:49 UTC 2021
      ​
      System load:    2.38
      Processes:  67
      Memory used:    3.1%
      Swap used:  0.0%
      Usage On:   4%
      IP address:     192.168.11.27
      Users online:   1
      ​
      ​
      [root@openEuler-RISCV-rare ~]#
      

      ​
      执行df -h查看D1磁盘空间大小

      [root@openEuler-RISCV-rare ~]# df -h
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/root        29G  1.1G   27G   4% /
      devtmpfs        996M     0  996M   0% /dev
      tmpfs          1000M     0 1000M   0% /dev/shm
      tmpfs          1000M  1.7M  999M   1% /run
      tmpfs          1000M     0 1000M   0% /sys/fs/cgroup
      tmpfs          1000M     0 1000M   0% /tmp
      tmpfs           200M     0  200M   0% /run/user/0
      

      在D1上执行ifconfig查询其IP地址,将JDK镜像通过SSH方式复制到D1的/dev/root目录下

      D:\jean>scp -r OpenJDK11U-jdk_riscv64_linux_bisheng_2021-06-01-18-05.tar.gz root@192.168.11.27:/root
      The authenticity of host '192.168.11.27 (192.168.11.27)' can't be established.
      ECDSA key fingerprint is SHA256:VT2faxMh5NQxvxSF02D0P7wxOL4rb6shfTtcnjiSdd8.
      Are you sure you want to continue connecting (yes/no)?
      Warning: Permanently added '192.168.11.27' (ECDSA) to the list of known hosts.
      root@192.168.11.27's password:
      OpenJDK11U-jdk_riscv64_linux_bisheng_2021-06-01-18-05.tar.gz                          100%  165MB 339.0KB/s   08:17
      

      解压JDK镜像,将其解压到/root/java目录下

      [root@openEuler-RISCV-rare ~]# tar -zxvf OpenJDK11U-jdk_riscv64_linux_bisheng_2021-06-01-18-05.tar.gz -C /root/java/
      

      进入/root/java/jdk-11.0.10+9/bin,执行./java -version验证java环境是否可以正常使用

      [root@openEuler-RISCV-rare bin]# ./java -version
      openjdk version "11.0.10" 2021-01-19
      OpenJDK Runtime Environment Bisheng-11.0.10+9-202106011819 (build 11.0.10+9-202106011819)
      OpenJDK 64-Bit Server VM Bisheng-11.0.10+9-202106011819 (build 11.0.10+9-202106011819, mixed mode)
      

      将hello world脚本通过ssh方式复制到D1的/root目录下

      D:\jean>scp -r ./code/helloworld.java root@192.168.11.27:/root
      root@192.168.11.27's password:
      helloworld.java                                                                       100%  125    25.2KB/s   00:00
      

      在D1的/root/java/jdk-11.0.10+9/bin目录下,执行hello world脚本,可以成功执行

      [root@openEuler-RISCV-rare bin]# ./java /root/helloworld.java
      Hello World
      
      1 Reply Last reply Reply Quote Share 0
      • 1 / 1
      • First post
        Last post

      Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策