This article describes how to use Register Transfer Level (RTL) compiler on an f1 instance.
- All the operations described in this article must be performed by one account in the same region.
- We strongly recommend that you use an f1 instance as a RAM user. To avoid unwanted operations, you must authorize the RAM user to perform required actions only. You must create a role for the RAM user and grant temporary permissions to the role to access the OSS buckets. If you want to encrypt the IP address, grant the RAM user to use Key Management Service (KMS). If you want the RAM user to check permissions, authorize the RAM user to view the resources of an account.
Before you begin, complete the following:
- Create an f1 instance and add a security group rule to allow Internet access to SSH Port 22 of the instance.
Note: Only the image we share with you can be used on an f1 instance. For more information, see Create an f1 instance.
- To operate an f1 instance as a RAM user, do the following:
- Activate OSS and create an OSS bucket to upload your files. The OSS bucket and the f1 instance must be owned by one account and operated in the same region.
- Log on to the
ECS consoleto obtain the instance ID.
- For encryption, activate Key Management Service (KMS).
To use RTL compiler on an f1 instance, follow these steps.
Run the script to configure the basic environment.
Run the following commands to compile the project.
Note: It takes a long time to compile the project.
To create an image, follow these steps:
Run the following commands to initialize faascmd.
# If needed, add the environment variable and grant permission to run the commands.
chmod +x /opt/dcp1_0/script/faascmd
# Replace hereIsMySecretId with your AccessKey ID. Replace hereIsMySecretKey with your AccessKey Secret.
faascmd config --id=hereIsMySecretId --key=hereIsMySecretKey
# Replace hereIsMyBucket with the OSS bucket name in the China East 1 region.
faascmd auth --bucket=hereIsMyBucket
Make sure you are at the /opt/dcp1_0/hw/samples/dma_afu directory, and run the command to upload the gbs file.
faascmd upload_object --object=dma_afu.gbs --file=dma_afu.gbs
Run the command to create an image.
# Replace hereIsYourImageName with your image name.
faascmd create_image --object=dma_afu.gbs --fpgatype=intel --name=hereIsYourImageName --tags=hereIsYourImageTag --encrypted=false --shell=V0.11
To download the image, follow these steps:
faascmd list_imagescommand to check whether the image is created.
"State":"success"exists in the returned result, it means the image is created. Record the FpgaImageUUID.
Run the command to obtain FPGA ID.
# Replace hereIsYourInstanceId with your f1 instance ID.
faascmd list_instances --instanceId=hereIsYourInstanceId
Record FpgaUUID in the returned result.
Run the command to download the image to your f1 instance.
# Replace hereIsYourInstanceID with your f1 instance ID. Replace hereIsFpgaUUID with your FpgaUUID. Replace hereIsImageUUID with your FpgaImageUUID.
faascmd download_image --instanceId=hereIsYourInstanceID --fpgauuid=hereIsFpgaUUID --fpgatype=intel --imageuuid=hereIsImageUUID --imagetype=afu --shell=V0.11
Run the command to check whether the image is downloaded.
# Replace hereIsYourInstanceID with your f1 instance ID. Replace hereIsFpgaUUID with your FpgaUUID.
faascmd fpga_status --instanceId=hereIsYourInstanceID --fpgauuid=hereIsFpgaUUID
"TaskStatus":"operating"exists in the returned result, and the displayed FpgaImageUUID is identical with your recorded FpgaImageUUID, the image is downloaded.
Run the commands one by one for test.
sudo LD_LIBRARY_PATH=/opt/dcp1_0/hw/samples/dma_afu/sw:$LD_LIBRARY_PATH ./fpga_dma_test 0
If the following result is returned, the test is completed.
Note: If the Huge pages feature is not enabled, run the following command to enable it.
sudo bash -c "echo 20 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"